jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes JComboBox with Vector Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JComboBox with Vector" Watch "JComboBox with Vector" New topic

JComboBox with Vector

Guy Shahar

Joined: Dec 23, 2005
Posts: 22
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

Joined: Jun 09, 2003
Posts: 4632
seems to work OK like this

Guy Shahar

Joined: Dec 23, 2005
Posts: 22
Thanks Michael. I have messed around a bit and found a way to make it work (not sure how).
I agree. Here's the link: http://aspose.com/file-tools
subject: JComboBox with Vector
It's not a secret anymore!