Example usage for java.awt.event WindowEvent getWindow

List of usage examples for java.awt.event WindowEvent getWindow

Introduction

In this page you can find the example usage for java.awt.event WindowEvent getWindow.

Prototype

public Window getWindow() 

Source Link

Document

Returns the originator of the event.

Usage

From source file:org.jets3t.apps.uploader.Uploader.java

/**
 * Run the Uploader as a stand-alone application.
 *
 * @param args/*from  ww w.j  a v  a2  s  . co m*/
 * @throws Exception
 */
public static void main(String args[]) throws Exception {
    JFrame ownerFrame = new JFrame("JetS3t Uploader");
    ownerFrame.addWindowListener(new WindowListener() {
        public void windowOpened(WindowEvent e) {
        }

        public void windowClosing(WindowEvent e) {
            e.getWindow().dispose();
        }

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

    // Read arguments as properties of the form: <propertyName>'='<propertyValue>
    Properties argumentProperties = new Properties();
    if (args.length > 0) {
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            int delimIndex = arg.indexOf("=");
            if (delimIndex >= 0) {
                String name = arg.substring(0, delimIndex);
                String value = arg.substring(delimIndex + 1);
                argumentProperties.put(name, value);
            } else {
                System.out.println("Ignoring property argument with incorrect format: " + arg);
            }
        }
    }

    new Uploader(ownerFrame, argumentProperties);
}

From source file:org.jets3t.apps.cockpit.Cockpit.java

/**
 * Runs Cockpit as a stand-alone application.
 * @param args//from   ww w.  j  a v a 2s  .co  m
 * @throws Exception
 */
public static void main(String args[]) throws Exception {
    // When running on OS X, display app menu in the right place (i.e. not the app window)
    System.setProperty("apple.laf.useScreenMenuBar", "true");

    JFrame ownerFrame = new JFrame("JetS3t Cockpit");
    ownerFrame.addWindowListener(new WindowListener() {
        public void windowOpened(WindowEvent e) {
        }

        public void windowClosing(WindowEvent e) {
            e.getWindow().dispose();
        }

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

    new Cockpit(ownerFrame);
}

From source file:Main.java

public static void activateWindowClosingButton(JFrame frame) {
    frame.addWindowListener(new WindowAdapter() {
        @Override//from w w w . ja  v  a 2  s .co m
        public void windowClosing(WindowEvent evnt) {
            evnt.getWindow().setVisible(false);
            evnt.getWindow().dispose();
        }
    });
}

From source file:Main.java

public static void activateWindowClosingAndSystemExitButton(JFrame frame) {
    frame.addWindowListener(new WindowAdapter() {
        @Override/*from  w  w  w  . ja  v  a 2s . co  m*/
        public void windowClosing(WindowEvent evnt) {
            evnt.getWindow().setVisible(false);
            evnt.getWindow().dispose();
            System.exit(0);
        }
    });
}

From source file:Main.java

protected void processWindowEvent(WindowEvent e) {
    System.out.println(e.getWindow());
    super.processWindowEvent(e); // Pass on the event
}

From source file:Main.java

public void windowOpened(WindowEvent e) {
    initComp.requestFocus();
    e.getWindow().removeWindowListener(this);
}

From source file:projectvendingmachine.AmountPieChart.java

@Override
public void windowClosing(final WindowEvent evt) {
    if (evt.getWindow() == this) {
        dispose();//from  w w  w .  j  av  a  2  s.co  m
    }
}

From source file:org.geotools.renderer.chart.GeometryRendererTest.java

void showChart(XYPlot plot) throws Exception {
    JFreeChart chart = new JFreeChart(plot);
    chart.setAntiAlias(true);/*from  w ww  .ja v  a  2s.  c  o  m*/
    ChartPanel panel = new ChartPanel(chart, true);

    final String headless = System.getProperty("java.awt.headless", "false");
    if (!headless.equalsIgnoreCase("true") && TestData.isInteractiveTest()) {
        try {
            JFrame frame = new JFrame(getName());
            frame.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    e.getWindow().dispose();
                }
            });
            frame.setContentPane(panel);
            frame.setSize(new Dimension(500, 500));
            frame.setVisible(true);

            Thread.sleep(5000);
            frame.dispose();
        } catch (HeadlessException exception) {
            // The test is running on a machine without X11 display. Ignore.
            return;
        }
    }
}

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

/**
 * Listens for the main window closing, and shuts down the application.
 *
 * @param event  information about the window event.
 *//*from  www  . j  a  v  a2  s .  c o m*/
@Override
public void windowClosing(WindowEvent event) {
    if (event.getWindow() == this) {
        dispose();
        System.exit(0);
    }
}

From source file:com.mirth.connect.plugins.rtfviewer.RTFViewer.java

@Override
public void viewAttachments(List<String> attachmentIds) {
    // do viewing code

    Frame frame = new Frame("RTF Viewer");

    frame.setLayout(new BorderLayout());

    try {//from   w w w . j a va  2s. c om

        Attachment attachment = parent.mirthClient.getAttachment(attachmentIds.get(0));
        byte[] rawRTF = Base64.decodeBase64(attachment.getData());
        JEditorPane jEditorPane = new JEditorPane("text/rtf", new String(rawRTF));

        if (jEditorPane.getDocument().getLength() == 0) {
            // decoded when it should not have been.  i.e.) the attachment data was not encoded.
            jEditorPane.setText(new String(attachment.getData()));
        }

        jEditorPane.setEditable(false);
        JScrollPane scrollPane = new javax.swing.JScrollPane();
        scrollPane.setViewportView(jEditorPane);
        frame.add(scrollPane);
        frame.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
                e.getWindow().dispose();
            }
        });

        frame.setSize(600, 800);

        Dimension dlgSize = frame.getSize();
        Dimension frmSize = parent.getSize();
        Point loc = parent.getLocation();

        if ((frmSize.width == 0 && frmSize.height == 0) || (loc.x == 0 && loc.y == 0)) {
            frame.setLocationRelativeTo(null);
        } else {
            frame.setLocation((frmSize.width - dlgSize.width) / 2 + loc.x,
                    (frmSize.height - dlgSize.height) / 2 + loc.y);
        }

        frame.setVisible(true);
    } catch (Exception e) {
        parent.alertException(parent, e.getStackTrace(), e.getMessage());
    }
}