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 {
public static void main (String [] args) {
new Main ();
}
public Main () {
...
}
}
Create window
JFrame frame = new JFrame();
Customize window
frame.setSize (300, 300);
frame.setLayout (new FlowLayout ());
Create a button
JButton b1 = new JButton ("Push me");
Add button to window
frame.add (b1);
Show the window
frame.setVisible (true);