import java.awt.*; import java.awt.event.*; /** * First try at laying out the components. No good!! */ public class ConverterDemo0 extends Frame { Button btnConvert, btnClear, btnExit; Label lblFrom, lblTo; TextField tfFrom, tfTo; ConverterDemo0 () { super("Unit Conversion Demo"); // call a parent constructor // (must come first) btnConvert = new Button("Convert"); btnClear = new Button("Clear"); btnExit = new Button("Exit"); lblFrom = new Label("FROM:"); lblTo = new Label("TO:"); tfFrom = new TextField(20); tfTo = new TextField(20); // It is surprising that the compiler allows the following // since the layout manager is border layout. add(lblFrom); add(lblTo); add(tfFrom); add(tfTo); add(btnConvert); add(btnClear); add(btnExit); setBounds(400,300,300, 200); pack(); setVisible(true); this.addWindowListener(new WindowAdapter () { public void windowClosing(WindowEvent wev) { dispose(); } } ); } /* public static void main(String [] args) { new ConverterDemo0(); } */ }