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