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:XMLTreeView.java

public static void main(String args[]) {
    JFrame frame = new JFrame("XMLTreeView: [ games.xml ]");
    frame.setSize(400, 400);/* w  w  w .j a  v a 2s . com*/

    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent ev) {
            System.exit(0);
        }
    });
    file = "games.xml";
    new XMLTreeView(frame);
}

From source file:LabelForComboBox.java

public static void main(String[] a) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from w ww . ja va 2  s.co m*/
        }
    });
    f.getContentPane().add(new LabelForComboBox());
    f.pack();
    f.setSize(new Dimension(300, 200));
    f.show();

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    JFrame frm = new JFrame("Main");
    Image im = Toolkit.getDefaultToolkit().getImage("c:\\icons\\icon1.png");
    TrayIcon tri = new TrayIcon(im);
    tri.addActionListener(e -> {/*from w w w.  java  2 s . com*/
        frm.setVisible(true);
        try {
            SystemTray.getSystemTray().remove(tri);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    });
    frm.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            try {
                SystemTray.getSystemTray().add(tri);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            frm.setVisible(false);
        }
    });
    frm.setSize(100, 100);
    frm.setVisible(true);
}

From source file:BasicStrokeDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from   ww  w  .  j av  a  2 s . c  o m
        }
    });
    BasicStrokeDemo p = new BasicStrokeDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(250, 250));
    f.show();
}

From source file:ThickStrokeDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from  w  w w .  jav  a  2 s .co m*/
        }
    });
    ThickStrokeDemo p = new ThickStrokeDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(250, 250));
    f.show();
}

From source file:Main.java

public static void main(String[] argv) {
    JFrame frame = new Main();
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//  ww w.  j  a  va 2s  .c  om
        }
    });

    frame.pack();
    frame.setVisible(true);
}

From source file:GradientPaintDemo.java

public static void main(String s[]) {
    JFrame f = new JFrame();
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);//from   www.j a  v a2 s .  c o m
        }
    });
    GradientPaintDemo p = new GradientPaintDemo();
    f.getContentPane().add("Center", p);
    p.init();
    f.pack();
    f.setSize(new Dimension(250, 250));
    f.show();
}

From source file:MainClass.java

public static void main(String[] argv) {
    JFrame frame = new MainClass();
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from  w  ww.  j  a va2 s .c  o m*/
        }
    });

    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    device.setFullScreenWindow(frame);//from www.j  a  v  a  2 s.  c  o  m
    device.setDisplayMode(new DisplayMode(800, 600, 32, 60));

    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowIconified(WindowEvent we) {
            if (programmatic) {
                programmatic = false;
                frame.setState(JFrame.NORMAL);
            }
        }
    });

    JButton btn = new JButton();
    btn.setText("Btn");
    final JPanel panel = new JPanel();

    panel.add(btn);
    frame.add(panel);

    btn.addActionListener(e -> {
        programmatic = true;
        JOptionPane.showMessageDialog(panel, "Sample");
    });
    frame.setVisible(true);
}

From source file:XORPanel.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setTitle("XOR");
    frame.setSize(300, 200);//from w  w w  .  jav a  2s .  c o  m
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    Container contentPane = frame.getContentPane();
    contentPane.add(new XORPanel());

    frame.show();
}