Search in sources :

Example 1 with WindowEvent

use of java.awt.event.WindowEvent in project zookeeper by apache.

the class ZooInspector method main.

/**
     * @param args
     *            - not used. The value of these parameters will have no effect
     *            on the application
     */
public static void main(String[] args) {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        JFrame frame = new JFrame("ZooInspector");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        iconResource = new IconResource();
        final ZooInspectorPanel zooInspectorPanel = new ZooInspectorPanel(new ZooInspectorManagerImpl(), iconResource);
        frame.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosed(WindowEvent e) {
                super.windowClosed(e);
                zooInspectorPanel.disconnect(true);
            }
        });
        frame.setContentPane(zooInspectorPanel);
        frame.setSize(1024, 768);
        frame.setVisible(true);
    } catch (Exception e) {
        LoggerFactory.getLogger().error("Error occurred loading ZooInspector", e);
        JOptionPane.showMessageDialog(null, "ZooInspector failed to start: " + e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }
}
Also used : ZooInspectorManagerImpl(org.apache.zookeeper.inspector.manager.ZooInspectorManagerImpl) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) IconResource(org.apache.zookeeper.inspector.gui.IconResource) WindowAdapter(java.awt.event.WindowAdapter) ZooInspectorPanel(org.apache.zookeeper.inspector.gui.ZooInspectorPanel)

Example 2 with WindowEvent

use of java.awt.event.WindowEvent in project qi4j-sdk by Qi4j.

the class Envisage method showMainFrame.

private void showMainFrame() {
    mainFrame = new EnvisageFrame(application);
    mainFrame.setLocationByPlatform(true);
    mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    mainFrame.setSize(new Dimension(1024, 768));
    mainFrame.setVisible(true);
    mainFrame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowOpened(WindowEvent evt) {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    mainFrame.initQi4J();
                }
            });
        }
    });
}
Also used : WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter) Dimension(java.awt.Dimension)

Example 3 with WindowEvent

use of java.awt.event.WindowEvent in project jreversepro by akkumar.

the class GUIMain method addListeners.

/**
   * Method to add property listeners to MenuItems and the MainFrame.
   */
private void addListeners() {
    mMbrGen.onFileOpen.addActionListener(this);
    mMbrGen.onFileSave.addActionListener(this);
    mMbrGen.onFileExit.addActionListener(this);
    mMbrGen.onEditCut.addActionListener(this);
    mMbrGen.onEditCopy.addActionListener(this);
    mMbrGen.onViewCPool.addActionListener(this);
    mMbrGen.onOptFont.addActionListener(this);
    mMbrGen.onHelpAbout.addActionListener(this);
    addWindowListener(new WindowAdapter() {

        /**
       * WindowClosing event handler.
       * 
       * @param aEvent
       *          Event generated.
       */
        @Override
        public void windowClosing(WindowEvent aEvent) {
            appClose();
            super.windowClosing(aEvent);
        }
    });
}
Also used : WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Example 4 with WindowEvent

use of java.awt.event.WindowEvent in project jmonkeyengine by jMonkeyEngine.

the class TestSafeCanvas method main.

public static void main(String[] args) throws InterruptedException {
    AppSettings settings = new AppSettings(true);
    settings.setWidth(640);
    settings.setHeight(480);
    final TestSafeCanvas app = new TestSafeCanvas();
    app.setPauseOnLostFocus(false);
    app.setSettings(settings);
    app.createCanvas();
    app.startCanvas(true);
    JmeCanvasContext context = (JmeCanvasContext) app.getContext();
    Canvas canvas = context.getCanvas();
    canvas.setSize(settings.getWidth(), settings.getHeight());
    Thread.sleep(3000);
    JFrame frame = new JFrame("Test");
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            app.stop();
        }
    });
    frame.getContentPane().add(canvas);
    frame.pack();
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
    Thread.sleep(3000);
    frame.getContentPane().remove(canvas);
    Thread.sleep(3000);
    frame.getContentPane().add(canvas);
}
Also used : JmeCanvasContext(com.jme3.system.JmeCanvasContext) AppSettings(com.jme3.system.AppSettings) JFrame(javax.swing.JFrame) Canvas(java.awt.Canvas) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Example 5 with WindowEvent

use of java.awt.event.WindowEvent in project jmonkeyengine by jMonkeyEngine.

the class TestAwtPanels method createWindowForPanel.

private static void createWindowForPanel(AwtPanel panel, int location) {
    JFrame frame = new JFrame("Render Display " + location);
    frame.getContentPane().setLayout(new BorderLayout());
    frame.getContentPane().add(panel, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            if (++panelsClosed == 2) {
                app.stop();
            }
        }
    });
    frame.pack();
    frame.setLocation(location, Toolkit.getDefaultToolkit().getScreenSize().height - 400);
    frame.setVisible(true);
}
Also used : BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Aggregations

WindowEvent (java.awt.event.WindowEvent)184 WindowAdapter (java.awt.event.WindowAdapter)128 JPanel (javax.swing.JPanel)41 JButton (javax.swing.JButton)38 BorderLayout (java.awt.BorderLayout)35 JFrame (javax.swing.JFrame)35 Dimension (java.awt.Dimension)31 ActionEvent (java.awt.event.ActionEvent)31 JLabel (javax.swing.JLabel)30 JScrollPane (javax.swing.JScrollPane)25 ActionListener (java.awt.event.ActionListener)23 GridBagConstraints (java.awt.GridBagConstraints)19 GridBagLayout (java.awt.GridBagLayout)19 FlowLayout (java.awt.FlowLayout)17 Insets (java.awt.Insets)14 Frame (java.awt.Frame)12 JTextArea (javax.swing.JTextArea)12 Container (java.awt.Container)11 JDialog (javax.swing.JDialog)11 IOException (java.io.IOException)9