FileDocCategorySizeDatePackage
ListDemo.javaAPI DocExample655Sun Feb 08 21:23:56 GMT 2004None

ListDemo

public class ListDemo extends Frame
Demonstrate old AWT ScrollingList. Note: You should normally use a Swing JList instead.

Fields Summary
List
list
Constructors Summary
ListDemo(String s)


	  
		super(s);
		setLayout(new FlowLayout());
		list = new List(10, false);
		list.add("Hello");
		list.add("Goodbye");
		list.addItemListener(new ItemListener() {
			public void itemStateChanged(ItemEvent e) {
				System.out.println("Selected: " + list.getSelectedItem());
			}
		});

		add(list);
	
Methods Summary
public static voidmain(java.lang.String[] s)

		ListDemo l = new ListDemo("Up and down the list");
		l.pack();
		l.setVisible(true);