// File: GridLayout2.java import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class GridLayout2 extends Applet { private Button showFrame; private TextField status; private Label label; private TextArea address; MsgFrame msgFrame; String FrameTitle = "Message Frame"; public void init() { setLayout(new GridLayout(2,2,20,20)); showFrame = new Button("Show Frame"); showFrame.addActionListener(new ButtonHandler2(this)); status = new TextField(5); label = new Label("Another example of GridLayout"); 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); add(showFrame); add(status); add(label); add(address); } } class ButtonHandler2 implements ActionListener { GridLayout2 grid; public ButtonHandler2(GridLayout2 g) { grid = g; } public void actionPerformed(ActionEvent e) { grid.msgFrame = new MsgFrame(grid.FrameTitle); } } class MsgFrame extends Frame implements ActionListener { MsgFrame (String title) { super(title); Button okButton = new Button("OK"); okButton.addActionListener(this); setLayout(new FlowLayout()); add(okButton); setSize(200,70); setVisible(true); } public void actionPerformed(ActionEvent e) { setVisible(false); } }