Forums Register Login

actionevent in jcombobox of jtable

+Pie Number of slices to send: Send
Hi,
I'm not able to use actionlistener in selecting value of jcombobox with arrow keys. This jcombobox is in a jtable.
The actionlistener works fine only if an enter key is pressed, but not for every select with arow.

+Pie Number of slices to send: Send
That's because the selection does not change yet. You could try to get a hold of the JList that is actually used, and add a ListSelectionListener to that.

Some investigation has lead me to interface javax.swing.plaf.basic.ComboPopup which has a getList method, but that's as far as I got at the moment. I haven't been able to find out how to get a reference to this from a JComboBox reference. Perhaps you can get a bit further now you have a start where to look.
+Pie Number of slices to send: Send
. . . and Massimo, welcome to JavaRanch
+Pie Number of slices to send: Send
Now I use the code:



setting the renderer:



and It's work fine.
Thanks Massimo
+Pie Number of slices to send: Send
It could cause problems though. That will be triggered anytime any element of your list is painted. That includes when opening the drop down list. It might cause the wrong element to be set.
Do you want ants? Because that's how you get ants. And a tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4588 times.
Similar Threads
JTable numeric validation
? Trying to implement ListSelectionModel on an AbstractTableModel
problem clicking jbuttons in jtable
Custom Cell renderer... A solution?
adding and manipulating elements of a CCombo
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 07:40:16.