// File: FlowLayout1.java import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class FlowLayout1 extends Applet implements ActionListener, ItemListener{ private TextField name; private Label label; private TextArea address; private Choice fruits; private Button press_me; private List list; public void init() { setLayout(new FlowLayout(10)); name = new TextField(30); label = new Label("Name: ", Label.LEFT); name.addActionListener(this); String add="Northeast Parallel Architectures Center (NPAC) \n" + "111 College Place, \n" + "Syracuse, NY 13244-4100"; address = new TextArea(add,4,35); address.setEditable(false); fruits = new Choice(); fruits.addItem("Apples"); fruits.addItem("Oranges"); fruits.addItem("Strawberries"); fruits.addItemListener(this); press_me = new Button("Press Me"); press_me.addActionListener(this); list = new List(3, false); list.addItem("Java"); list.addItem("JavaScript"); list.addItem("VRML"); list.addActionListener(this); list.addItemListener(this); add(label); add(name); add(address); add(fruits); add(press_me); add(list); } public void actionPerformed( ActionEvent e) { showStatus(" STATUS> ACTION: "+e.getActionCommand()); } public void itemStateChanged(ItemEvent e) { if (e.getItemSelectable()==fruits) showStatus(" STATUS> ITEM: "+fruits.getSelectedItem()); else if (e.getItemSelectable()==list) showStatus(" STATUS> ITEM: "+list.getSelectedItem()); } }