• Post Reply Bookmark Topic Watch Topic
  • New Topic

knowing when JComboBox's data has changed  RSS feed

 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have a custom JComboBox class where I set a ToolTip for each item. It works in times when I send a populated vector to the class. However, sometimes I need to send an empty vector and populate it later. How can I find out in custom JCB class when my vector has changed in number of elements?
I tried to use ListDataListener, but had problems in implementing it.
thanks,
Alex
 
Shashi Kanta
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alex,
As for making your JComboBox listen to events, you can add an ItemListener to it.
And as for finding out if the vector has changed it's size, you can check the size of the vector, in the ItemStateChanged() method, using Vector class's method size() which will return the number of elements currently in the vector.
I hope that's the question you asked!
Shashi
 
Alex Kravets
Ranch Hand
Posts: 476
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Shashi,
I did add ItemListener. The problem is that I implement ToolTip for each item of JCB, and routine to fire ToolTip with ItemListener only works when someone selects item from JCB, goes back to JCB and hovers over an item. I don't want that. I want ToolTip array filled up when data in JCB's vector has changed, that's why I need help with ListDataListener.
thanks,
Alex
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!