Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JComboBox and JList

843805Apr 16 2006 — edited Apr 16 2006
hey, i've got a JList - flightsList - and 2 JComboBoxes - from, to. I want to have the list of the flights to appear in each of the 2 combo boxes, but i dnt know how. Please help!! Thanks!!

JPanel topPanel = new JPanel();

topPanel.add( new JLabel( "From:" ) );
from = new JComboBox();

topPanel.add( from );

topPanel.add( new JLabel( "To:" ) );
to = new JComboBox();

topPanel.add( to );

topPanel.add( new JLabel( "Date:" ) );
date = new JTextField( 10 );
topPanel.add( date);

JButton button = new JButton( "Query" );
topPanel.add( button );

contents.add( topPanel, BorderLayout.NORTH);

flightsList = new JList();
contents.add( new JScrollPane( flightsList) , BorderLayout.CENTER );

JPanel buttons = new JPanel();

I have defined the following at the top:

private JComboBox from;
private JComboBox to;
private JTextField date;
private JList flightsList;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 14 2006
Added on Apr 16 2006
1 comment
435 views