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

public static void main(String s[]) {

    JFrame f = new JFrame("BufferedShapeMover");
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from  ww w  . jav a2s  .  c om*/
        }
    });
    f.getContentPane().setLayout(new BorderLayout());
    f.getContentPane().add(new BufferedDraw(), "Center");

    f.pack();
    f.setSize(new Dimension(550, 250));
    f.show();
}

From source file:CustomScrollPane.java

public static void main(String[] args) {
    JFrame f = new JFrame("JScrollBar Demo");
    f.setSize(300, 250);/*ww  w.  ja  v  a2s  .  c o m*/

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

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

    final JFrame f = new JFrame("FileTree Drop and Drop Example");
    try {
        final FileTree tree = new FileTree("D:\\");

        // Add a drop target to the FileTree
        FileTreeDropTarget target = new FileTreeDropTarget(tree);

        // Add a drag source to the FileTree
        FileTreeDragSource source = new FileTreeDragSource(tree);

        tree.setEditable(true);

        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) {
                tree.setEditable(editable.isSelected());
            }
        });

        final JCheckBox enabled = new JCheckBox("Enabled");
        enabled.setSelected(true);
        panel.add(enabled);
        enabled.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                tree.setEnabled(enabled.isSelected());
            }
        });

        f.getContentPane().add(new JScrollPane(tree), BorderLayout.CENTER);
        f.getContentPane().add(panel, BorderLayout.SOUTH);
        f.setSize(500, 400);
        f.setVisible(true);
    } catch (Exception e) {
        System.out.println("Failed to build GUI: " + e);
    }
}

From source file:Pear.java

public static void main(String s[]) {
    JFrame f = new JFrame("Pear");
    f.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);/*from  w w  w .  ja  v  a  2 s .c o m*/
        }
    });
    JApplet applet = new Pear();
    f.getContentPane().add("Center", applet);
    applet.init();
    f.pack();
    f.setSize(new Dimension(150, 200));
    f.show();
}

From source file:LineStyles.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  w  w  .  jav a 2  s  .c  om*/
        }
    });
    f.setContentPane(new LineStyles());
    f.setSize(450, 200);
    f.setVisible(true);
}

From source file:UIDefaultsTreeModel.java

public static void main(String[] args) {
    JFrame treeFrame1 = new JFrame();

    JScrollPane jScrollPane1 = new JScrollPane();
    JTree jTree1 = new JTree(new UIDefaultsTreeModel());

    treeFrame1.setSize(new Dimension(400, 300));
    treeFrame1.addWindowListener(new WindowAdapter() {
        public void windowClosed(WindowEvent e) {
            System.exit(0);/*from   w  w w .  j  a  v a2  s .  c  om*/
        }
    });
    treeFrame1.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    treeFrame1.getContentPane().add(jScrollPane1, BorderLayout.CENTER);
    jScrollPane1.getViewport().add(jTree1, null);

    treeFrame1.setVisible(true);
}

From source file:Clock.java

public static void main(String[] a) {
    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
        }
    });
    Clock c = new Clock();
    f.getContentPane().add("Center", c);
    f.pack();
    f.setSize(new Dimension(300, 300));
    f.show();

}

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 w  w w  . j a v  a2  s  .co m
    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:BoxLayoutPane.java

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

    f.setContentPane(new BoxLayoutPane());
    f.pack();
    f.setVisible(true);
}

From source file:org.jfree.chart.demo.MemoryUsageDemo.java

public static void main(String args[]) {
    JFrame jframe = new JFrame("Memory Usage Demo");
    MemoryUsageDemo memoryusagedemo = new MemoryUsageDemo(30000);
    jframe.getContentPane().add(memoryusagedemo, "Center");
    jframe.setBounds(200, 120, 600, 280);
    jframe.setVisible(true);/*from ww w  . j av a  2s.  c o  m*/
    (memoryusagedemo.new DataGenerator(100)).start();
    jframe.addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent windowevent) {
            System.exit(0);
        }

    });
}