Search in sources :

Example 6 with WindowListener

use of java.awt.event.WindowListener in project JMRI by JMRI.

the class LinkingLabelTest method tearDown.

@Override
protected void tearDown() {
    if (panel != null) {
        // now close panel window
        java.awt.event.WindowListener[] listeners = panel.getTargetFrame().getWindowListeners();
        for (WindowListener listener : listeners) {
            panel.getTargetFrame().removeWindowListener(listener);
        }
        junit.extensions.jfcunit.TestHelper.disposeWindow(panel.getTargetFrame(), this);
        panel = null;
    }
    apps.tests.Log4JFixture.tearDown();
}
Also used : WindowListener(java.awt.event.WindowListener)

Example 7 with WindowListener

use of java.awt.event.WindowListener in project JMRI by JMRI.

the class MemorySpinnerIconTest method tearDown.

@Override
protected void tearDown() {
    // now close panel window
    if (panel != null) {
        java.awt.event.WindowListener[] listeners = panel.getTargetFrame().getWindowListeners();
        for (WindowListener listener : listeners) {
            panel.getTargetFrame().removeWindowListener(listener);
        }
        junit.extensions.jfcunit.TestHelper.disposeWindow(panel.getTargetFrame(), this);
    }
    apps.tests.Log4JFixture.tearDown();
}
Also used : WindowListener(java.awt.event.WindowListener)

Example 8 with WindowListener

use of java.awt.event.WindowListener in project JMRI by JMRI.

the class MemoryIconTest method tearDown.

@Override
protected void tearDown() throws Exception {
    // now close panel window
    if (panel != null) {
        java.awt.event.WindowListener[] listeners = panel.getTargetFrame().getWindowListeners();
        for (WindowListener listener : listeners) {
            panel.getTargetFrame().removeWindowListener(listener);
        }
        junit.extensions.jfcunit.TestHelper.disposeWindow(panel.getTargetFrame(), this);
    }
    super.tearDown();
    apps.tests.Log4JFixture.tearDown();
    JUnitUtil.resetInstanceManager();
}
Also used : WindowListener(java.awt.event.WindowListener)

Example 9 with WindowListener

use of java.awt.event.WindowListener in project DistributedFractalNetwork by Budder21.

the class FractalChooserMenu method chooseFractal.

/**
	 * Allows a user to choose a saved fractal and set zoom speed and resolution
	 * parameters
	 * @return a RenderManger for the network to use. Will return null if no fractal if the window is closed
	 */
public static RenderManager chooseFractal() {
    waiting = true;
    manager = null;
    JFrame f = new JFrame();
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    JLabel message = new JLabel(" Fractal:");
    message.setFont(Constants.mediumFont);
    p.add(message, BorderLayout.WEST);
    RoundedButton chooseFile = new RoundedButton();
    chooseFile.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
            }
            JFileChooser fileChooser = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Fractal", "prop");
            fileChooser.setFileFilter(filter);
            manager = new RenderManager(fileChooser.getSelectedFile());
        }
    });
    p.add(chooseFile, BorderLayout.CENTER);
    f.setContentPane(p);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setResizable(false);
    f.addWindowListener(new WindowListener() {

        public void windowOpened(WindowEvent e) {
        }

        public void windowClosed(WindowEvent e) {
        }

        public void windowIconified(WindowEvent e) {
        }

        public void windowDeiconified(WindowEvent e) {
        }

        public void windowActivated(WindowEvent e) {
        }

        public void windowDeactivated(WindowEvent e) {
        }

        @Override
        public void windowClosing(WindowEvent e) {
            waiting = false;
        }
    });
    f.setVisible(true);
    while (manager == null || waiting) {
    }
    return manager;
}
Also used : JPanel(javax.swing.JPanel) WindowListener(java.awt.event.WindowListener) RoundedButton(menus.RoundedButton) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent)

Example 10 with WindowListener

use of java.awt.event.WindowListener in project DistributedFractalNetwork by Budder21.

the class Display method run.

/**
	 * This contains one of the main logic loops of this class. It starts by creating the JFrame the display
	 * is shown in. After that, it enters a loop where every few seconds it will ask the server for updates
	 */
@Override
public void run() {
    JFrame f = new JFrame("Network");
    f.setContentPane(this);
    f.pack();
    f.setResizable(false);
    f.setLocationRelativeTo(null);
    f.setVisible(true);
    f.addWindowListener(new WindowListener() {

        public void windowOpened(WindowEvent e) {
        }

        public void windowClosed(WindowEvent e) {
        }

        public void windowIconified(WindowEvent e) {
        }

        public void windowDeiconified(WindowEvent e) {
        }

        public void windowActivated(WindowEvent e) {
        }

        public void windowDeactivated(WindowEvent e) {
        }

        @Override
        public void windowClosing(WindowEvent e) {
            System.out.println("closing");
            running = false;
            server.setDisplay(null);
        }
    });
    updateParameters(server.getAdminParameters());
    while (running) {
        try {
            t.sleep(5000);
        } catch (InterruptedException e) {
            log.addError(e);
        }
        updateParameters(server.getAdminParameters());
    }
}
Also used : WindowListener(java.awt.event.WindowListener) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent)

Aggregations

WindowListener (java.awt.event.WindowListener)18 WindowEvent (java.awt.event.WindowEvent)7 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 JFrame (javax.swing.JFrame)2 BorderLayout (java.awt.BorderLayout)1 Component (java.awt.Component)1 Dialog (java.awt.Dialog)1 Frame (java.awt.Frame)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 Window (java.awt.Window)1 WindowAdapter (java.awt.event.WindowAdapter)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Preferences (java.util.prefs.Preferences)1 JComponent (javax.swing.JComponent)1 JFileChooser (javax.swing.JFileChooser)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1