JComboBox and JList
843805Apr 16 2006 — edited Apr 16 2006hey, 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;