Example usage for java.awt.event WindowAdapter WindowAdapter

List of usage examples for java.awt.event WindowAdapter WindowAdapter

Introduction

In this page you can find the example usage for java.awt.event WindowAdapter WindowAdapter.

Prototype

WindowAdapter

Source Link

Usage

From source file:TextAcceleratorExample.java

public static void main(String[] args) {
    try {/*ww  w .  j a v a2  s. c  o  m*/
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {
    }

    JLabel l;
    JTextField t;
    JButton b;
    JFrame f = new JFrame("Text Accelerator Example");
    Container cp = f.getContentPane();
    cp.setLayout(new GridBagLayout());
    cp.setBackground(UIManager.getColor("control"));
    GridBagConstraints c = new GridBagConstraints();

    c.gridx = 0;
    c.gridy = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.insets = new Insets(2, 2, 2, 2);
    c.anchor = GridBagConstraints.EAST;

    cp.add(l = new JLabel("Name:", SwingConstants.RIGHT), c);
    l.setDisplayedMnemonic('n');
    cp.add(l = new JLabel("House/Street:", SwingConstants.RIGHT), c);
    l.setDisplayedMnemonic('h');
    cp.add(l = new JLabel("City:", SwingConstants.RIGHT), c);
    l.setDisplayedMnemonic('c');
    cp.add(l = new JLabel("State/County:", SwingConstants.RIGHT), c);
    l.setDisplayedMnemonic('s');
    cp.add(l = new JLabel("Zip/Post code:", SwingConstants.RIGHT), c);
    l.setDisplayedMnemonic('z');
    cp.add(l = new JLabel("Telephone:", SwingConstants.RIGHT), c);
    l.setDisplayedMnemonic('t');
    cp.add(b = new JButton("Clear"), c);
    b.setMnemonic('l');

    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;

    cp.add(t = new JTextField(35), c);
    t.setFocusAccelerator('n');
    c.gridx = 1;
    c.gridy = GridBagConstraints.RELATIVE;
    cp.add(t = new JTextField(35), c);
    t.setFocusAccelerator('h');
    cp.add(t = new JTextField(35), c);
    t.setFocusAccelerator('c');
    cp.add(t = new JTextField(35), c);
    t.setFocusAccelerator('s');
    cp.add(t = new JTextField(35), c);
    t.setFocusAccelerator('z');
    cp.add(t = new JTextField(35), c);
    t.setFocusAccelerator('t');
    c.weightx = 0.0;
    c.fill = GridBagConstraints.NONE;
    cp.add(b = new JButton("OK"), c);
    b.setMnemonic('o');

    f.pack();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            System.exit(0);
        }
    });
    f.setVisible(true);
}

From source file:URLMonitorPanel.java

public static void main(String[] args) throws Exception {
    JFrame frame = new JFrame("URL Monitor");
    Container c = frame.getContentPane();
    c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));
    Timer t = new Timer();
    String[] u = new String[] { "http://www.java2s.com", "http://www.java2s.com" };

    for (int i = 0; i < u.length; i++) {
        c.add(new URLMonitorPanel(u[i], t));
    }/*from  www  .java 2  s  .c o m*/
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent evt) {
            System.exit(0);
        }
    });
    frame.pack();
    frame.show();
}

From source file:MultipartFileUploadApp.java

public static void main(String[] args) {

    MultipartFileUploadFrame f = new MultipartFileUploadFrame();
    f.setTitle("HTTP multipart file upload application");
    f.pack();//from w ww. j  a va2 s .co m
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    f.setVisible(true);
}

From source file:mulavito.samples.GraphAlgorithmDemo.java

public static void main(String[] args) {
    // Schedule a job for the event-dispatching thread:
    // creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
        @Override/* w ww  .ja  v  a  2  s  .co m*/
        public void run() {
            GraphAlgorithmDemo main = new GraphAlgorithmDemo();
            main.addWindowListener(new WindowAdapter() {
                @Override
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            });
        }
    });
}

From source file:MainClass.java

public static void main(String[] args) {
    Frame frame = new Frame("AppletAndApp as an Application");
    myApplet = new MainClass();

    frame.add(new Panel().add(myApplet));

    frame.addNotify();//from  w  w w  .j  av  a2s  .com

    myApplet.setStub(myStub = new MyStub(args));
    myApplet.init();

    frame.setSize(300, 200);
    frame.setVisible(true);

    myStub.setActive(true);
    myApplet.start();

    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent w) {
            myStub.setActive(false);
            myApplet.stop();
            myApplet.destroy();
            System.exit(0);
        }
    });
}

From source file:Starry.java

public static void main(String[] args) {
    Image starry = new ImageIcon("yourFile.gif").getImage();

    StarPanel starPanel = new StarPanel(starry);

    JFrame f = new JFrame("Starry");
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from   w  w  w.  ja va  2  s  .c  o m
        }
    });

    f.getContentPane().add(starPanel, BorderLayout.CENTER);
    f.setSize(new Dimension(550, 200));
    f.setVisible(true);
}

From source file:TexturedText.java

/** "main program" method - construct and show */
public static void main(String[] av) {
    // create a TexturedText object, tell it to show up
    final Frame f = new Frame("TexturedText");
    TexturedText comp = new TexturedText();
    f.add(comp);/*from w  w  w . j  a  v a2 s.  c o  m*/
    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);
}

From source file:ChartPanel.java

public static void main(String[] argv) {
    JFrame f = new JFrame();
    f.setSize(400, 300);//  w w w  .  j  a  v  a 2 s . c o  m
    double[] values = new double[3];
    String[] names = new String[3];
    values[0] = 1;
    names[0] = "Item 1";

    values[1] = 2;
    names[1] = "Item 2";

    values[2] = 4;
    names[2] = "Item 3";

    f.getContentPane().add(new ChartPanel(values, names, "title"));

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    f.addWindowListener(wndCloser);
    f.setVisible(true);
}

From source file:MouseDragActionPanel.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setTitle("MouseTest");
    frame.setSize(300, 200);//from  w  w w. j  a v  a2 s. c  o  m
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    Container contentPane = frame.getContentPane();
    contentPane.add(new MouseDragActionPanel());

    frame.show();
}

From source file:ColorGradient.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from ww w  .  ja  v a2  s .  com
        }
    });
    ColorGradient g = new ColorGradient();
    g.init();

    f.setContentPane(g);
    f.setSize(600, 200);
    f.setVisible(true);
}