import javax.swing.JFrame; import javax.swing.JButton; import java.awt.event.*; public class FirstWindow extends JFrame { public static final int WIDTH = 300; public static final int HEIGHT = 200; public FirstWindow() { super(); setSize(WIDTH, HEIGHT); setTitle("First Window Program!"); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); JButton endButton = new JButton("Click to end program."); ActionListener buttonEar = new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }; endButton.addActionListener(buttonEar); add(endButton); } public static void main(String[] args) { FirstWindow w = new FirstWindow(); w.setVisible(true); } }