Search in sources :

Example 11 with WindowListener

use of java.awt.event.WindowListener in project bytecode-viewer by Konloch.

the class ShowAllStrings method execute.

@Override
public void execute(final ArrayList<ClassNode> classNodeList) {
    final PluginConsole frame = new PluginConsole("Show All Strings");
    final AtomicBoolean complete = new AtomicBoolean(false);
    final Thread backgroundThread = new Thread() {

        public void run() {
            try {
                for (ClassNode classNode : classNodeList) {
                    for (Object o : classNode.fields.toArray()) {
                        FieldNode f = (FieldNode) o;
                        Object v = f.value;
                        if (v instanceof String) {
                            String s = (String) v;
                            if (!s.isEmpty()) {
                                frame.appendText(String.format("%s.%s%s -> \"%s\"", classNode.name, f.name, f.desc, s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")));
                            }
                        }
                        if (v instanceof String[]) {
                            for (int i = 0; i < ((String[]) v).length; i++) {
                                String s = ((String[]) v)[i];
                                if (!s.isEmpty()) {
                                    frame.appendText(String.format("%s.%s%s[%s] -> \"%s\"", classNode.name, f.name, f.desc, i, s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")));
                                }
                            }
                        }
                    }
                    for (Object o : classNode.methods.toArray()) {
                        MethodNode m = (MethodNode) o;
                        InsnList iList = m.instructions;
                        for (AbstractInsnNode a : iList.toArray()) {
                            if (a instanceof LdcInsnNode) {
                                if (((LdcInsnNode) a).cst instanceof String) {
                                    final String s = (String) ((LdcInsnNode) a).cst;
                                    if (!s.isEmpty()) {
                                        frame.appendText(String.format("%s.%s%s -> \"%s\"", classNode.name, m.name, m.desc, s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")));
                                    }
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {
                new ExceptionUI(e, "konloch@gmail.com");
            } finally {
                complete.set(true);
            }
        }
    };
    frame.setVisible(true);
    frame.addWindowListener(new WindowListener() {

        @Override
        public void windowClosing(WindowEvent e) {
            backgroundThread.stop();
            complete.set(true);
        }

        @Override
        public void windowOpened(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) {
        }
    });
    backgroundThread.start();
    while (!complete.get()) ;
}
Also used : WindowListener(java.awt.event.WindowListener) ExceptionUI(the.bytecode.club.bytecodeviewer.api.ExceptionUI) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) WindowEvent(java.awt.event.WindowEvent) PluginConsole(the.bytecode.club.bytecodeviewer.api.PluginConsole)

Example 12 with WindowListener

use of java.awt.event.WindowListener in project ACS by ACS-Community.

the class Manager method initializeGUI.

/**
	 * Initialize GUI.
	 */
public void initializeGUI() {
    setSize(320, 200);
    setLayout(new GridBagLayout());
    setTitle("ACS Manager");
    add(getRequestsProgressBar(), new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(40, 40, 40, 40), 0, 0));
    guiUpdaterTimer = new Timer(GUI_UPDATE_INTERVAL, new GUIUpdater());
    guiUpdaterTimer.start();
    setLocationByPlatform(true);
    setVisible(true);
    toFront();
    addWindowListener(new WindowListener() {

        /* (non-Javadoc)
			 * @see java.awt.event.WindowListener#windowActivated(java.awt.event.WindowEvent)
			 */
        public void windowActivated(WindowEvent event) {
        }

        /* (non-Javadoc)
			 * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
			 */
        public void windowClosed(WindowEvent event) {
        }

        /* (non-Javadoc)
			 * @see java.awt.event.WindowListener#windowClosing(java.awt.event.WindowEvent)
			 */
        public void windowClosing(WindowEvent event) {
            destroy();
        }

        /* (non-Javadoc)
			 * @see java.awt.event.WindowListener#windowDeactivated(java.awt.event.WindowEvent)
			 */
        public void windowDeactivated(WindowEvent event) {
        }

        /* (non-Javadoc)
			 * @see java.awt.event.WindowListener#windowDeiconified(java.awt.event.WindowEvent)
			 */
        public void windowDeiconified(WindowEvent event) {
        }

        /* (non-Javadoc)
			 * @see java.awt.event.WindowListener#windowIconified(java.awt.event.WindowEvent)
			 */
        public void windowIconified(WindowEvent event) {
        }

        /* (non-Javadoc)
			 * @see java.awt.event.WindowListener#windowOpened(java.awt.event.WindowEvent)
			 */
        public void windowOpened(WindowEvent event) {
        }
    });
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) WindowListener(java.awt.event.WindowListener) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Timer(javax.swing.Timer) WindowEvent(java.awt.event.WindowEvent)

Example 13 with WindowListener

use of java.awt.event.WindowListener in project jdk8u_jdk by JetBrains.

the class JOptionPane method createDialog.

private JDialog createDialog(Component parentComponent, String title, int style) throws HeadlessException {
    final JDialog dialog;
    Window window = JOptionPane.getWindowForComponent(parentComponent);
    if (window instanceof Frame) {
        dialog = new JDialog((Frame) window, title, true);
    } else {
        dialog = new JDialog((Dialog) window, title, true);
    }
    if (window instanceof SwingUtilities.SharedOwnerFrame) {
        WindowListener ownerShutdownListener = SwingUtilities.getSharedOwnerFrameShutdownListener();
        dialog.addWindowListener(ownerShutdownListener);
    }
    initDialog(dialog, style, parentComponent);
    return dialog;
}
Also used : Window(java.awt.Window) Frame(java.awt.Frame) WindowListener(java.awt.event.WindowListener) Dialog(java.awt.Dialog)

Example 14 with WindowListener

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

the class SignalMastIconTest method tearDown.

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

Example 15 with WindowListener

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

the class IndicatorTurnoutIconTest 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)

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