Lecture Notes/Android Basics

Basic Framework : Java SWING Program

kingjung 2010. 6. 3. 20:58

import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class SWINGCaseFive extends JFrame implements ActionListener  {
             public static final int WIDTH = 300;
             public static final int HEIGHT = 200;

 public SWINGCaseFive() {
    setTitle("Swing Case 5");
    setSize(WIDTH, HEIGHT);
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    JButton endButton = new JButton("Click to End the Program");
    endButton.addActionListener(this);
    getContentPane().add(endButton);
    setVisible(true);
 }

 public static void main(String[] args) {
    new SWINGCaseFive();
 }

 public void actionPerformed(ActionEvent e) {
    System.exit(0);
 }

}