• Post Reply Bookmark Topic Watch Topic
  • New Topic

JComboBox: Telling difference if model update or actual select.

 
Manuel Petermann
Ranch Hand
Posts: 177
Hibernate Linux Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again.
I got a problem with the action/itemlistener of a JCombobox.
Is there a way to tell the difference if the model was updated via addElement or an item was selected?
The ActionCommand of both is the same.
Problem is, i update the comboboxmodel via a swingworker so no way to know when it is updating.
Any ideas?
 
Darryl Burke
Bartender
Posts: 5154
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • Remove the listener
  • Update the model
  • Add the listener

  •  
    Manuel Petermann
    Ranch Hand
    Posts: 177
    Hibernate Linux Python
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    That is a rather blunt way to do it. I thought that there might be a better way to it.
    But if thats not the case I think i will implement that.
     
    Darryl Burke
    Bartender
    Posts: 5154
    11
    Java Netbeans IDE Opera
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    If you prefer:
  • Set a boolean flag
  • Update the model
  • Reset the flag


  • In the listener, test the flag
  •  
    Consider Paul's rocket mass heater.
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!