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()) ;
}
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) {
}
});
}
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;
}
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();
}
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();
}
Aggregations