Example usage for java.awt.event WindowEvent WindowEvent

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

Introduction

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

Prototype

public WindowEvent(Window source, int id) 

Source Link

Document

Constructs a WindowEvent object.

Usage

From source file:forge.screens.deckeditor.DeckImport.java

/**
 * Instantiates a new deck import.//from   w ww  . j a  v  a 2  s. c  o m
 * 
 * @param g
 *            the g
 */
public DeckImport(final ACEditorBase<TItem, TModel> g) {
    this.host = g;

    final int wWidth = 700;
    final int wHeight = 600;

    this.setPreferredSize(new java.awt.Dimension(wWidth, wHeight));
    this.setSize(wWidth, wHeight);
    this.setTitle("Deck Importer");

    txtInput.setFocusable(true);
    txtInput.setEditable(true);

    FSkin.SkinColor foreColor = FSkin.getColor(FSkin.Colors.CLR_TEXT);
    this.scrollInput.setBorder(new FSkin.TitledSkinBorder(BorderFactory.createEtchedBorder(),
            "Paste or type a decklist", foreColor));
    this.scrollOutput.setBorder(new FSkin.TitledSkinBorder(BorderFactory.createEtchedBorder(),
            "Expect the recognized lines to appear", foreColor));
    this.scrollInput.setViewportBorder(BorderFactory.createLoweredBevelBorder());
    this.scrollOutput.setViewportBorder(BorderFactory.createLoweredBevelBorder());

    this.add(this.scrollInput, "cell 0 0, w 50%, growy, pushy");
    this.add(this.newEditionCheck, "cell 0 1, w 50%, ax c");
    this.add(this.dateTimeCheck, "cell 0 2, w 50%, ax c");

    this.add(monthDropdown, "cell 0 3, w 20%, ax left, split 2, pad 0 4 0 0");
    this.add(yearDropdown, "w 15%");
    fillDateDropdowns();

    this.add(this.onlyCoreExpCheck, "cell 0 4, w 50%, ax c");

    this.add(this.scrollOutput, "cell 1 0, w 50%, growy, pushy");
    this.add(this.summaryMain, "cell 1 1, label");
    this.add(this.summarySide, "cell 1 2, label");

    this.add(this.cmdAccept, "cell 1 4, split 2, w 150, align r, h 26");
    this.add(this.cmdCancel, "w 150, h 26");

    this.cmdCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            DeckImport.this.processWindowEvent(new WindowEvent(DeckImport.this, WindowEvent.WINDOW_CLOSING));
        }
    });

    this.cmdAccept.addActionListener(new ActionListener() {
        @SuppressWarnings("unchecked")
        @Override
        public void actionPerformed(final ActionEvent e) {
            final String warning = "This will replace contents of your currently open deck with whatever you are importing. Proceed?";
            if (!FOptionPane.showConfirmDialog(warning, "Replacing old deck")) {
                return;
            }
            final Deck toSet = DeckImport.this.buildDeck();
            DeckImport.this.host.getDeckController().setModel((TModel) toSet);
            DeckImport.this.processWindowEvent(new WindowEvent(DeckImport.this, WindowEvent.WINDOW_CLOSING));
        }
    });

    ActionListener updateDateCheck = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            boolean isSel = dateTimeCheck.isSelected();
            monthDropdown.setEnabled(isSel);
            yearDropdown.setEnabled(isSel);
            parseAndDisplay();
        }
    };
    this.dateTimeCheck.addActionListener(updateDateCheck);

    ActionListener reparse = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            parseAndDisplay();
        }
    };
    this.newEditionCheck.addActionListener(reparse);
    this.onlyCoreExpCheck.addActionListener(reparse);
    this.yearDropdown.addActionListener(reparse);
    this.monthDropdown.addActionListener(reparse);
    updateDateCheck.actionPerformed(null); // update actual state

    this.txtInput.getDocument().addDocumentListener(new OnChangeTextUpdate());
    this.cmdAccept.setEnabled(false);
}

From source file:ch.unibas.fittingwizard.application.Visualization.java

public void close() {
    if (jmolWindow != null) {
        jmolWindow.dispatchEvent(new WindowEvent(jmolWindow, WindowEvent.WINDOW_CLOSING));
    }
}

From source file:nl.xs4all.home.freekdb.b52reader.gui.MainGuiTest.java

@Test
public void testShutdownApplication() throws InterruptedException, InvocationTargetException {
    MainGui mainGui = new MainGui(mockManyBrowsersPanel);
    mainGui.setMainCallbacks(mockMainCallbacks);

    mainGui.initializeBackgroundBrowsersPanel(mockFrame, mockConfiguration);
    mainGui.initializeGui(new ArrayList<>());

    waitForGuiTasks();/*from  w w  w .  ja v a  2 s . c  o  m*/

    windowListener.windowClosing(new WindowEvent(mockFrame, WindowEvent.WINDOW_CLOSING));

    assertTrue(shutdownApplicationWasCalled);
}

From source file:org.zaproxy.zap.extension.customFire.ScanProgressDialog.java

private JButton getCloseButton() {
    // Note that on Linux dialogs dont get close buttons on the frame decoration
    if (closeButton == null) {
        closeButton = new JButton("Close");
        closeButton.addActionListener(new ActionListener() {
            @Override// w ww .  j a  v a2s  .  com
            public void actionPerformed(ActionEvent e) {
                dispatchEvent(new WindowEvent(ScanProgressDialog.this, WindowEvent.WINDOW_CLOSING));
            }
        });
    }
    return closeButton;
}

From source file:org.zaproxy.zap.extension.ascan.ScanProgressDialog.java

private JButton getCloseButton() {
    // Note that on Linux dialogs dont get close buttons on the frame decoration
    if (closeButton == null) {
        closeButton = new JButton(Constant.messages.getString("all.button.close"));
        closeButton.addActionListener(new ActionListener() {
            @Override//from   w  w w.  j  a va 2 s. c o m
            public void actionPerformed(ActionEvent e) {
                dispatchEvent(new WindowEvent(ScanProgressDialog.this, WindowEvent.WINDOW_CLOSING));
            }
        });
    }
    return closeButton;
}

From source file:org.parosproxy.paros.view.FindDialog.java

/**
 * This method initializes btnCancel   /*from   ww  w .j ava2s .c  om*/
 *    
 * @return javax.swing.JButton   
 */
private JButton getBtnCancel() {
    if (btnCancel == null) {
        btnCancel = new JButton();
        btnCancel.setText(Constant.messages.getString("edit.find.button.cancel"));
        btnCancel.addActionListener(new java.awt.event.ActionListener() {

            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {

                FindDialog.this.discard();
                FindDialog.this.dispatchEvent(new WindowEvent(FindDialog.this, WindowEvent.WINDOW_CLOSING));
            }
        });

    }
    return btnCancel;
}

From source file:Forms.CreateGearForm.java

private void lintSpec(final GearSpec spec) {
    LintGearSpecWorker worker = new LintGearSpecWorker(spec) {
        @Override/*from ww w . ja  v  a  2  s . com*/
        protected void done() {
            super.done();

            if (result.getPassed()) {
                if (saveSpec(spec)) {
                    JFrame frame = (JFrame) SwingUtilities.getWindowAncestor(MasterPanel);
                    frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
                }
            } else {
                showLintErrorDialog(result);
            }
        }
    };
    worker.execute();
}

From source file:org.apache.tika.gui.TikaGUI.java

public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    if ("openfile".equals(command)) {
        int rv = chooser.showOpenDialog(this);
        if (rv == JFileChooser.APPROVE_OPTION) {
            openFile(chooser.getSelectedFile());
        }/*from   w  w  w . ja  va 2s  .  co m*/
    } else if ("openurl".equals(command)) {
        Object rv = JOptionPane.showInputDialog(this, "Enter the URL of the resource to be parsed:", "Open URL",
                JOptionPane.PLAIN_MESSAGE, null, null, "");
        if (rv != null && rv.toString().length() > 0) {
            try {
                openURL(new URL(rv.toString().trim()));
            } catch (MalformedURLException exception) {
                JOptionPane.showMessageDialog(this, "The given string is not a valid URL", "Invalid URL",
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    } else if ("html".equals(command)) {
        layout.show(cards, command);
    } else if ("text".equals(command)) {
        layout.show(cards, command);
    } else if ("main".equals(command)) {
        layout.show(cards, command);
    } else if ("xhtml".equals(command)) {
        layout.show(cards, command);
    } else if ("metadata".equals(command)) {
        layout.show(cards, command);
    } else if ("json".equals(command)) {
        layout.show(cards, command);
    } else if ("about".equals(command)) {
        textDialog("About Apache Tika", TikaGUI.class.getResource("about.html"));
    } else if ("exit".equals(command)) {
        Toolkit.getDefaultToolkit().getSystemEventQueue()
                .postEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
    }
}

From source file:LoginUI.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) throws ParseException {
    HashMap<String, String> userpw = getUserInfo();
    String inputuser = jTextField1.getText();
    char[] inputpw = jTextField2.getPassword();
    String pw = new String(inputpw);
    //wrong username
    if (!userpw.containsKey(inputuser)) {
        JOptionPane.showMessageDialog(null, "Username does not exist!", "Failed", JOptionPane.ERROR_MESSAGE);
    }/*from w  w w.  ja v  a2 s  . co m*/

    // wrong password
    else if (!userpw.get(inputuser).equals(pw)) {
        JOptionPane.showMessageDialog(null, "Incorrect Password", "Failed", JOptionPane.ERROR_MESSAGE);
    }

    else {
        MainGUI main = new MainGUI(inputuser);
        JOptionPane.showMessageDialog(null, "Login Successful!", "Success!", JOptionPane.INFORMATION_MESSAGE);
        WindowEvent winClosingEvent = new WindowEvent(this, WindowEvent.WINDOW_CLOSING);
        Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent);

        main.setVisible(true);
    }
}

From source file:org.barcelonamedia.uima.tools.docanalyzer.DBAnnotationViewerDialog.java

/**
 * Create an AnnotationViewer Dialog/*from w w w.  j  a v a  2  s .c o  m*/
 * 
 * @param aParentFrame
 *          frame containing this panel
 * @param aTitle
 *          title to display for the dialog
 * @param aInputDir
 *          directory containing input files (in XCAS foramt) to read
 * @param aStyleMapFile
 *          filename of style map to be used to view files in HTML
 * @param aPerformanceStats
 *          string representaiton of performance statistics, optional.
 * @param aTypeSystem
 *          the CAS Type System to which the XCAS files must conform.
 * @param aTypesToDisplay
 *          array of types that should be highlighted in the viewer. This can be set to the output
 *          types of the Analysis Engine. A value of null means to display all types.
 */
/*public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
  File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem,
  final String[] aTypesToDisplay, String interactiveTempFN, boolean javaViewerRBisSelected,
  boolean javaViewerUCRBisSelected, boolean xmlRBisSelected, CAS cas) {
  super(aParentFrame, aDialogTitle);
  // create the AnnotationViewGenerator (for HTML view generation)
  this.med1 = med;
  this.cas = cas;
  annotationViewGenerator = new AnnotationViewGenerator(tempDir);
        
  launchThatViewer(med.getOutputDir(), interactiveTempFN, aTypeSystem, aTypesToDisplay,
    javaViewerRBisSelected, javaViewerUCRBisSelected, xmlRBisSelected, aStyleMapFile,
    tempDir);
}*/

public DBAnnotationViewerDialog(JFrame aParentFrame, String aDialogTitle, DBPrefsMediator med,
        File aStyleMapFile, String aPerformanceStats, TypeSystem aTypeSystem, final String[] aTypesToDisplay,
        boolean generatedStyleMap, CAS cas) {

    super(aParentFrame, aDialogTitle);

    this.xmiDAO = med.getXmiDAO();

    this.med1 = med;
    this.cas = cas;

    styleMapFile = aStyleMapFile;
    final String performanceStats = aPerformanceStats;
    typeSystem = aTypeSystem;
    typesToDisplay = aTypesToDisplay;

    // create the AnnotationViewGenerator (for HTML view generation)
    annotationViewGenerator = new AnnotationViewGenerator(tempDir);

    // create StyleMapEditor dialog
    styleMapEditor = new StyleMapEditor(aParentFrame, cas);
    JPanel resultsTitlePanel = new JPanel();
    resultsTitlePanel.setLayout(new BoxLayout(resultsTitlePanel, BoxLayout.Y_AXIS));

    resultsTitlePanel.add(new JLabel("These are the Analyzed Documents."));
    resultsTitlePanel.add(new JLabel("Select viewer type and double-click file to open."));

    try {

        String[] documents = this.xmiDAO.getXMIList();
        analyzedResultsList = new JList(documents);

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.getViewport().add(analyzedResultsList, null);

        JPanel southernPanel = new JPanel();
        southernPanel.setLayout(new BoxLayout(southernPanel, BoxLayout.Y_AXIS));

        JPanel controlsPanel = new JPanel();
        controlsPanel.setLayout(new SpringLayout());

        Caption displayFormatLabel = new Caption("Results Display Format:");
        controlsPanel.add(displayFormatLabel);

        JPanel displayFormatPanel = new JPanel();
        displayFormatPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
        displayFormatPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
        javaViewerRB = new JRadioButton("Java Viewer");
        javaViewerUCRB = new JRadioButton("JV user colors");
        htmlRB = new JRadioButton("HTML");
        xmlRB = new JRadioButton("XML");

        ButtonGroup displayFormatButtonGroup = new ButtonGroup();
        displayFormatButtonGroup.add(javaViewerRB);
        displayFormatButtonGroup.add(javaViewerUCRB);
        displayFormatButtonGroup.add(htmlRB);
        displayFormatButtonGroup.add(xmlRB);

        // select the appropraite viewer button according to user's prefs
        javaViewerRB.setSelected(true); // default, overriden below

        if ("Java Viewer".equals(med.getViewType())) {
            javaViewerRB.setSelected(true);
        } else if ("JV User Colors".equals(med.getViewType())) {
            javaViewerUCRB.setSelected(true);
        } else if ("HTML".equals(med.getViewType())) {
            htmlRB.setSelected(true);
        } else if ("XML".equals(med.getViewType())) {
            xmlRB.setSelected(true);
        }

        displayFormatPanel.add(javaViewerRB);
        displayFormatPanel.add(javaViewerUCRB);
        displayFormatPanel.add(htmlRB);
        displayFormatPanel.add(xmlRB);

        controlsPanel.add(displayFormatPanel);

        SpringUtilities.makeCompactGrid(controlsPanel, 1, 2, // rows, cols
                4, 4, // initX, initY
                0, 0); // xPad, yPad

        JButton editStyleMapButton = new JButton("Edit Style Map");

        // event for the editStyleMapButton button
        editStyleMapButton.addActionListener(this);

        southernPanel.add(controlsPanel);

        // southernPanel.add( new JSeparator() );

        JPanel buttonsPanel = new JPanel();
        buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

        // APL: edit style map feature disabled for SDK
        buttonsPanel.add(editStyleMapButton);

        if (performanceStats != null) {
            JButton perfStatsButton = new JButton("Performance Stats");
            perfStatsButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    JOptionPane.showMessageDialog((Component) ae.getSource(), performanceStats, null,
                            JOptionPane.PLAIN_MESSAGE);
                }
            });
            buttonsPanel.add(perfStatsButton);
        }

        JButton closeButton = new JButton("Close");
        buttonsPanel.add(closeButton);

        southernPanel.add(buttonsPanel);

        // add list and panel container to Dialog
        getContentPane().add(resultsTitlePanel, BorderLayout.NORTH);
        getContentPane().add(scrollPane, BorderLayout.CENTER);
        getContentPane().add(southernPanel, BorderLayout.SOUTH);

        // event for the closeButton button
        closeButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                DBAnnotationViewerDialog.this.setVisible(false);
            }
        });

        // event for analyzedResultsDialog window closing
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        setLF(); // set default look and feel
        analyzedResultsList.setCellRenderer(new MyListCellRenderer());

        // doubleclicking on document shows the annotated result
        MouseListener mouseListener = new ListMouseAdapter();
        // styleMapFile, analyzedResultsList,
        // inputDirPath,typeSystem , typesToDisplay ,
        // javaViewerRB , javaViewerUCRB ,xmlRB ,
        // viewerDirectory , this);

        // add mouse Listener to the list
        analyzedResultsList.addMouseListener(mouseListener);
    } catch (DAOException e) {

        displayError(e.getMessage());

        this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
    }
}