Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JComboBox with Vector

 
Guy Shahar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to make a drop-down JComboBox with its options taken from a Vector. The problem is that when I add a new String to the Vector, the JComboBox becomes empty rather than displaying the updated options.

I had the same problem with a JList, but for this I was able to substitute a DefaultListModel for a Vector and it worked fine. Unfortunately, this option does not seem to be available for a JComboBox.

Can anybody help???
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
seems to work OK like this

 
Guy Shahar
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael. I have messed around a bit and found a way to make it work (not sure how).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic