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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -