aspose file tools
The moose likes Beginning Java and the fly likes JComboBox and ArrayList Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "JComboBox and ArrayList" Watch "JComboBox and ArrayList" New topic
Author

JComboBox and ArrayList

Kevin Magee
Greenhorn

Joined: Feb 02, 2002
Posts: 18
Hi,
I'm having problems filling a JComboBox with the
contents of an ArrayList.
The JComboBox is not appearing onscreen. I'm
using JPanel, and all other components are displayed except the combobox. This is my first time using swing, so any help would be greatly
appreciated.

Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
I don't really use swing. But I believe becuse of the hierarchy, you have to add a Jcombo box/Jlist to a frame, and then set the size and show the frame. I stand corrected though...


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Here is a simple example showing how to do this.
Kevin Magee
Greenhorn

Joined: Feb 02, 2002
Posts: 18
Thanks,
The code I had given was already a part of a program using JPanel and JFrame. I was just not sure of way JComboBoxes work, especially with
ArrayLists or Vectors.
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
If you notice you do not have to extract what you want in the box, just create a toString() for your class.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JComboBox and ArrayList
 
Similar Threads
Redrawing a JComboBox
JComboBox Action Issues.
how to store datecombobox in an arraylist of type combobox
Using a JComboBox to change the contents of another JComboBox
JTable selected row problem