This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes actionevent in jcombobox of jtable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "actionevent in jcombobox of jtable" Watch "actionevent in jcombobox of jtable" New topic
Author

actionevent in jcombobox of jtable

Massimo Perelli
Greenhorn

Joined: Jun 03, 2008
Posts: 2
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.

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

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.


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32644
    
    4
. . . and Massimo, welcome to JavaRanch
Massimo Perelli
Greenhorn

Joined: Jun 03, 2008
Posts: 2
Now I use the code:



setting the renderer:



and It's work fine.
Thanks Massimo
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: actionevent in jcombobox of jtable
 
Similar Threads
JTable numeric validation
adding and manipulating elements of a CCombo
Custom Cell renderer... A solution?
? Trying to implement ListSelectionModel on an AbstractTableModel
problem clicking jbuttons in jtable