Workshop: SimpleButton1

Import the classes you will use

import javax.swing.JFrame; 
import javax.swing.JButton;
import java.awt.FlowLayout;

Skeleton main program

public class Main extends JFrame {
    public static void main (String [] args) {
        new Main ();
    }

    public Main () {
        ...
    }
}

Window setup

setSize (300, 300);
setLayout (new FlowLayout ());

Create a button

JButton b1 = new JButton ("Push me");

Add button to window

add (b1);

Show the window

setVisible (true);