Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JComboBox Listener problem  RSS feed

 
Markus Schmider
Ranch Hand
Posts: 146
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello I have three JComboBoxes.
When the user selects an entry in the first JComboBox the entries in the second are set. For this I use an Action extends AbstractAction which is bound to the first JComboBox
I have also bound an Action to the second JComboBox.
Problem: this also fires when the entries on the second JCombox are added which leads to a Nullpointer.

I need a Listener which only reacts to user input, and does not react when the model of the JComboBox is changed.
 
Campbell Ritchie
Sheriff
Posts: 53760
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look in the Java Tutorials. It suggest an action listener, I think.
 
Rob Camick
Ranch Hand
Posts: 2753
11
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the ActionListener of the first combo box the basic code should be:

1) remove the listener from the second combo box
2) update the second combo box
3) restore the listener of the second combo box
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!