import java.util.*; import java.awt.*; public class SimplePanel extends Frame { public static void main(String[] argv) { Frame f = new SimplePanel(); f.resize(400, 300); f.show(); } // main public SimplePanel() { setTitle("Simple Panel"); Panel p = new Panel(); p.setLayout(new FlowLayout()); StartButton = new Button("start"); StopButton = new Button("stop"); InputButton = new Button("input"); Panel pb = new Panel(); pb.setLayout(new BorderLayout(2,2)); pb.add("North",StartButton); pb.add("South",StopButton); pb.add("West",InputButton); p.add(pb); // add the button panel to the panel Panel pt = new Panel(); pt.setLayout(new BorderLayout(2,2)); sign = new Label(" hello world : ", Label.RIGHT); text = new TextField("00000", 12); pt.add("East", sign); pt.add("West", text); p.add(pt); add("North", p); } // constructor public boolean handleEvent(Event evt) { if (evt.id == Event.WINDOW_DESTROY) System.exit(0); return super.handleEvent(evt); } // handleEvent public boolean action(Event evt, Object arg) { if (arg.equals("start")) { sign.setText("start button pressed"); } else if (arg.equals("stop")) { sign.setText("stop button pressed"); } else if (arg.equals("input")) { sign.setText(text.getText()); } else return super.action(evt,arg); return true; } // action private Button StartButton, StopButton, InputButton; private Label sign; private TextField text; }