java - JComboBox Selection Change Listener? -


i'm trying event fire whenever choice made jcombobox.

the problem i'm having there no obvious addselectionlistener() method.

i've tried use actionperformed() never fires.

short of overriding model jcombobox i'm out of ideas.

how notified of selection change on jcombobox?

edit: have apologize turns out using misbehaving subclass of jcombobox, i'll leave question since answer good. commence vote down. :)

it should respond actionlisteners, this:

combo.addactionlistener (new actionlistener () {     public void actionperformed(actionevent e) {         dosomething();     } }); 

@john calsbeek rightly points out additemlistener() work, too. may 2 itemevents, though, 1 deselection of selected item, , selection of new item. don't use both event types!


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -