/* * Simple button program */ import javax.swing.JFrame; //*1 Import the classes you need import java.awt.FlowLayout; //*1 public class Main extends JFrame { //*2 Subclass JFrame public static void main (String [] args) { //*3 Put code in constructor not main() new Main (); //*3 } public Main () { //*3 // Window setup setSize (300, 300); //*4 Optionally customize window setLayout (new FlowLayout ()); //*4 // Put a button in Button b1 = new Button ("Push me"); //*5 Create widgets add (b1); //*6 Add widgets to window // Put another button in Button b2 = new Button ("Push me also"); //*5 add (b2); //*6 // Show the window setVisible (true); //*7 Map window to screen } }