Example usage for javax.swing JFrame addWindowListener

List of usage examples for javax.swing JFrame addWindowListener

Introduction

In this page you can find the example usage for javax.swing JFrame addWindowListener.

Prototype

public synchronized void addWindowListener(WindowListener l) 

Source Link

Document

Adds the specified window listener to receive window events from this window.

Usage

From source file:com.joey.software.memoryToolkit.MemoryUsagePanel.java

/**
 * Entry point for the sample application.
 * //from   w ww . ja va 2 s  .com
 * @param args
 *            ignored.
 */
public static void main(String[] args) {
    JFrame frame = new JFrame("Memory Usage Demo");
    MemoryUsagePanel panel = new MemoryUsagePanel(500, 20);
    frame.getContentPane().add(panel, BorderLayout.CENTER);
    frame.setBounds(200, 120, 600, 280);
    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });

    panel.startUpdating();

    byte[][][] data = new byte[1024][1024][10];
}

From source file:CustomScrollPane.java

public static void main(String[] args) {
    JFrame f = new JFrame("JScrollBar Demo");
    f.setSize(300, 250);//from   ww  w .  j av a2  s . com

    ImageIcon icon = new ImageIcon("earth.jpg");
    CustomScrollPane myScrollPane = new CustomScrollPane(new JLabel(icon));
    f.getContentPane().add(myScrollPane);

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

}

From source file:unusedClasses.MemoryUsageDemo.java

public static void main(String[] paramArrayOfString) {
    JFrame localJFrame = new JFrame("Memory Usage Demo");
    MemoryUsageDemo localMemoryUsageDemo = new MemoryUsageDemo(30000);
    localJFrame.getContentPane().add(localMemoryUsageDemo, "Center");
    localJFrame.setBounds(200, 120, 600, 280);
    localJFrame.setVisible(true);//from   www  .  j a va2 s. c  om
    MemoryUsageDemo tmp56_55 = localMemoryUsageDemo;
    tmp56_55.getClass();
    tmp56_55.new DataGenerator(100).start();
    localJFrame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent paramWindowEvent) {
            System.exit(0);
        }
    });
}

From source file:de.tor.tribes.ui.algo.SettingsPanel.java

public static void main(String[] args) {
    try {//from w ww. java 2  s  . com
        //  UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
    } catch (Exception e) {
    }
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final SettingsPanel sp = new SettingsPanel(null);
    f.add(sp);
    f.addWindowListener(new WindowListener() {

        @Override
        public void windowOpened(WindowEvent e) {
        }

        @Override
        public void windowClosing(WindowEvent e) {
        }

        @Override
        public void windowClosed(WindowEvent e) {
        }

        @Override
        public void windowIconified(WindowEvent e) {
        }

        @Override
        public void windowDeiconified(WindowEvent e) {
        }

        @Override
        public void windowActivated(WindowEvent e) {
        }

        @Override
        public void windowDeactivated(WindowEvent e) {
        }
    });
    f.pack();
    f.setVisible(true);
}

From source file:MemoryMonitor.java

public static void main(String s[]) {
    final MemoryMonitor demo = new MemoryMonitor();
    WindowListener l = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*  ww  w  .  j  a  va  2s  .  c  om*/
        }

        public void windowDeiconified(WindowEvent e) {
            demo.surf.start();
        }

        public void windowIconified(WindowEvent e) {
            demo.surf.stop();
        }
    };
    JFrame f = new JFrame("MemoryMonitor");
    f.addWindowListener(l);
    f.getContentPane().add("Center", demo);
    f.pack();
    f.setSize(new Dimension(400, 500));
    f.setVisible(true);
    demo.surf.start();
    Thread thr = new Thread(new Memeater());
    thr.start();
}

From source file:MyCheckBoxUI.java

public static void main(String[] argv) {
    JFrame f = new JFrame();
    f.setSize(400, 300);//from w w w.  j a va2  s. c o m
    f.getContentPane().setLayout(new FlowLayout());

    JPanel p = new JPanel();
    JCheckBox bt1 = new JCheckBox("Click Me");
    bt1.setUI(new MyCheckBoxUI());
    p.add(bt1);
    f.getContentPane().add(p);
    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    f.addWindowListener(wndCloser);
    f.setVisible(true);
}

From source file:EditorDropTarget2.java

public static void main(String[] args) {
    try {/*from ww w  .ja va2s.c  om*/
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception evt) {
    }

    final JFrame f = new JFrame("JEditor Pane Drop Target Example 2");

    final JEditorPane pane = new JEditorPane();

    // Add a drop target to the JEditorPane
    EditorDropTarget2 target = new EditorDropTarget2(pane);

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

    JPanel panel = new JPanel();
    final JCheckBox editable = new JCheckBox("Editable");
    editable.setSelected(true);
    panel.add(editable);
    editable.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEditable(editable.isSelected());
        }
    });

    f.getContentPane().add(new JScrollPane(pane), BorderLayout.CENTER);
    f.getContentPane().add(panel, BorderLayout.SOUTH);
    f.setSize(500, 400);
    f.setVisible(true);
}

From source file:MyButtonUI.java

public static void main(String argv[]) {
    JFrame f = new JFrame();
    f.setSize(400, 300);/*from   w  w  w.  ja v a2s  . co m*/
    f.getContentPane().setLayout(new FlowLayout());

    JPanel p = new JPanel();
    JButton bt1 = new JButton("Click Me");
    bt1.setUI(new MyButtonUI());
    p.add(bt1);
    f.getContentPane().add(p);
    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    f.addWindowListener(wndCloser);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] argv) {
    JFrame f = new JFrame();
    f.setSize(400, 300);/*from w  ww  .j  ava2 s  .com*/
    Polygon p = new Polygon();
    p.addPoint(10, 10);
    p.addPoint(100, 300);
    p.addPoint(300, 300);
    p.addPoint(10, 10);

    PolygonButton btn = new PolygonButton(p, "button");
    f.getContentPane().add(btn);
    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    f.addWindowListener(wndCloser);
    f.setVisible(true);
}

From source file:EditorPaneExample11.java

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

    JFrame f = new EditorPaneExample11();

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