"main program" method - construct and show
// create a Swing object, tell it to show up
final JFrame f = new JFrame("Swing");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Swing comp = new Swing();
f.getContentPane().add(comp);
comp.quitButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
f.setVisible(false);
f.dispose();
System.exit(0);
}
});
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
f.setVisible(false);
f.dispose();
System.exit(0);
}
});
f.pack();
f.setLocation(200, 200);
f.setVisible(true);