Friday, March 11, 2005

How to write a Swing application

Program

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

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

    void createFrame() {
        setTitle(getClass().getName());
        createContentPane();
        createMenuBar();
        createToolBar();

        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });

        pack();
        setVisible(true);
    }

    void createContentPane() {
    }

    void createMenuBar() {
    }

    void createToolBar() {
    }
}

No comments: