You are on page 1of 1

// JLIST import java.awt.*; import java.awt.event.*; import javax.swing.

*; class ListExample extends JFrame { private JPanel topPanel; private JList listbox; public ListExample() { setTitle( "Simple ListBox Application" ); setSize( 300, 100 ); setBackground( Color.gray ); topPanel = new JPanel(); topPanel.setLayout( new BorderLayout() ); getContentPane().add( topPanel ); String listData[] = { "Item 1", "Item 2", "Item 3", "Item 4" }; listbox = new JList( listData ); topPanel.add( listbox, BorderLayout.CENTER ); } public static void main( String args[] ) { ListExample mainFrame = new ListExample(); mainFrame.setVisible( true ); } }

You might also like