| 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.
|
 |
 |
|
|
subject: JComboBox and ArrayList
|
|
|