1  import java.applet.Applet;
  2  import java.awt.*;
  3  
  4  public class GridLayout2 extends Applet {
  5    private Button showDialog;
  6    private TextField status;
  7    private Label label;
  8    private TextArea address;
  9    MsgDialog msgDialog;
 10    String dialogTitle = "Dialog Box";
 11  
 12    public void init() {
 13      setLayout(new GridLayout(2,2,20,20));
 14      showDialog = new Button("Show Dialog Box");
 15      status = new TextField(5);
 16      label = new Label("Another example of GridLayout");
 17      String add = "Northeast Parallel Architectures Center (NPAC) \n"
 18                    + "111 College Place, \n" + "Syracuse, NY 13244-4100";
 19  
 20      address = new TextArea(add,4,35);
 21      address.setEditable(false);
 22      add(showDialog);
 23      add(status);
 24      add(label);
 25      add(address);
 26    }
 27  
 28    public boolean action(Event evt, Object arg) {
 29      if (arg.equals("Show Dialog Box")) {
 30      msgDialog = new MsgDialog(dialogTitle);
 31      }
 32      else return super.action(evt,arg);
 33      return true;
 34    }
 35  }
 36  
 37  class MsgDialog extends Frame {
 38    MsgDialog(String title) {
 39      super(title);
 40      Button okButton = new Button("OK");
 41      setLayout(new FlowLayout());
 42      add(okButton);
 43      resize(200,70);
 44      show();
 45    }
 46    public boolean action(Event evt, Object arg) {
 47      if (arg.equals("OK")) {
 48        hide();
 49      }
 50      else return super.action(evt,arg);
 51      return true;
 52    }
 53  }  
 54