import java.awt.*; public class X { public static void main(String[] args) throws Exception { final Button b1 = new Button("Button1"); final Button b2 = new Button("Button2"); final Frame f = new Frame(); f.add(b1); f.add(b2); f.pack(); f.setVisible(true); } }