List of usage examples for java.awt.event WindowEvent WINDOW_CLOSING
int WINDOW_CLOSING
To view the source code for java.awt.event WindowEvent WINDOW_CLOSING.
Click Source Link
From source file:PVGraph.java
public PVGraph(Calendar date, int initialViewIndex) { super(WINDOW_TITLE_PREFIX); this.date = date; synchronized (graphs) { graphs.add(this); }/*from w w w . ja v a 2 s. com*/ views = new PVGraphView[4]; views[DAY_VIEW_INDEX] = new DayView(); views[MONTH_VIEW_INDEX] = new MonthView(); views[YEAR_VIEW_INDEX] = new YearView(); views[YEARS_VIEW_INDEX] = new YearsView(); tabPane = new JTabbedPane(); for (PVGraphView v : views) tabPane.addTab(v.getTabLabel(), v.makePanel()); tabPane.setSelectedIndex(initialViewIndex); setContentPane(tabPane); pack(); try { java.net.URL url = getClass().getResource("sun.png"); if (url != null) setIconImage(ImageIO.read(url)); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } ; setVisible(true); KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(new KeyEventDispatcher() { public boolean dispatchKeyEvent(KeyEvent ke) { Object src = ke.getSource(); if (src instanceof JComponent && ((JComponent) src).getRootPane().getContentPane() == tabPane) { if (ke.getID() == KeyEvent.KEY_TYPED) { switch (ke.getKeyChar()) { case 'd': tabPane.setSelectedIndex(DAY_VIEW_INDEX); return true; case 'm': tabPane.setSelectedIndex(MONTH_VIEW_INDEX); return true; case 'N' - 0x40: new PVGraph((Calendar) PVGraph.this.date.clone(), tabPane.getSelectedIndex()); return true; case 'Q' - 0x40: dispatchEvent(new WindowEvent(PVGraph.this, WindowEvent.WINDOW_CLOSING)); return true; case 'R' - 0x40: loadProperties(); updateView(); return true; case 'S': try { runSmatool(); updateView(); } catch (IOException ioe) { System.err.println(ioe.getMessage()); } return true; case 'y': tabPane.setSelectedIndex(YEAR_VIEW_INDEX); return true; case 'Y': tabPane.setSelectedIndex(YEARS_VIEW_INDEX); return true; default: return views[tabPane.getSelectedIndex()].handleKey(ke.getKeyChar()); } } } return false; } }); }
From source file:com.hartveld.commons.test.swing.AbstractSwingFrameTest.java
/** * Close the main application frame, releasing all resources. * * Closing the frame causes the UI lock to be released. * /* www. j a v a 2s .c om*/ * @see #waitForFrameToClose() */ protected final void closeFrame() { LOG.trace("Closing frame ..."); checkIsNotEDT(); LOG.trace("Delegating to EDT ..."); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { LOG.trace("Cleaning up UI resources ..."); frame.setVisible(false); frame.dispose(); LOG.trace("Firing WindowEvent ..."); final WindowEvent event = new WindowEvent(frame, WindowEvent.WINDOW_CLOSING); frame.dispatchEvent(event); } }); }
From source file:com.moneydance.modules.features.mdvenmoimporter.VenmoImporterWindow.java
public VenmoImporterWindow(Main extension) { super("VenmoImporter Console"); this.extension = extension; loadSettings();// w ww. j a v a 2 s . c o m setResizable(false); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); setBounds(100, 100, 516, 176); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(10, 10, 10, 10)); setContentPane(contentPane); contentPane.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, RowSpec.decode("8dlu"), FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblVenmoToken = new JLabel("Venmo Token"); lblVenmoToken.setHorizontalAlignment(SwingConstants.RIGHT); contentPane.add(lblVenmoToken, "2, 2"); venmoTokenField = new JTextField(venmoToken); venmoTokenField.setToolTipText(venmoTokenTooltip); contentPane.add(venmoTokenField, "4, 2, fill, default"); venmoTokenField.setColumns(50); JLabel lblAccount = new JLabel("Account"); contentPane.add(lblAccount, "2, 4, right, default"); targetAccountCombo = new JComboBox<>( new Vector<>(extension.getUnprotectedContext().getRootAccount().getSubAccounts())); contentPane.add(targetAccountCombo, "4, 4, fill, default"); if (targetAcctId != null) { targetAccountCombo.setSelectedItem( extension.getUnprotectedContext().getCurrentAccountBook().getAccountByUUID(targetAcctId)); } JLabel lblDescriptionFormat = new JLabel("Memo template"); contentPane.add(lblDescriptionFormat, "2, 6, right, default"); descriptionFormatField = new JTextField( descriptionFormat == null ? descriptionFormatDefault : descriptionFormat); descriptionFormatField.setToolTipText(descriptionFormatTooltip); contentPane.add(descriptionFormatField, "4, 6, fill, default"); descriptionFormatField.setColumns(10); panel = new JPanel(); panel.setBorder(null); contentPane.add(panel, "2, 8, 3, 1, fill, fill"); btnDelete = new JButton("Delete Settings"); panel.add(btnDelete); btnCancel = new JButton("Cancel"); panel.add(btnCancel); btnSave = new JButton("Save"); panel.add(btnSave); btnDownloadTransactions = new JButton("Download Transactions"); panel.add(btnDownloadTransactions); btnCancel.addActionListener(this); btnSave.addActionListener(this); btnDelete.addActionListener(this); btnDownloadTransactions.addActionListener(this); enableEvents(WindowEvent.WINDOW_CLOSING); }
From source file:forge.screens.deckeditor.DeckImport.java
/** * Instantiates a new deck import./*from w ww . jav a2s . 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:org.pegadi.client.LoginDialog.java
protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0);/*from ww w . ja v a2 s.c o m*/ } }
From source file:EventTestPane.java
/** Display Window events. Note the special handling of WINDOW_CLOSING */ public void processWindowEvent(WindowEvent e) { switch (e.getID()) { case WindowEvent.WINDOW_OPENED: showLine("WINDOW_OPENED"); break;/*from w w w . j a v a 2 s .c o m*/ case WindowEvent.WINDOW_CLOSED: showLine("WINDOW_CLOSED"); break; case WindowEvent.WINDOW_CLOSING: showLine("WINDOW_CLOSING"); break; case WindowEvent.WINDOW_ICONIFIED: showLine("WINDOW_ICONIFIED"); break; case WindowEvent.WINDOW_DEICONIFIED: showLine("WINDOW_DEICONIFIED"); break; case WindowEvent.WINDOW_ACTIVATED: showLine("WINDOW_ACTIVATED"); break; case WindowEvent.WINDOW_DEACTIVATED: showLine("WINDOW_DEACTIVATED"); break; } // If the user requested a window close, quit the program. // But first display a message, force it to be visible, and make // sure the user has time to read it. if (e.getID() == WindowEvent.WINDOW_CLOSING) { showLine("WINDOW_CLOSING event received."); showLine("Application will exit in 5 seconds"); // Force the updates to appear now. update(this.getGraphics()); // Wait five seconds try { Thread.sleep(5000); } catch (InterruptedException ie) { ; } // Exit now System.exit(0); } }
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 . j a v a 2s. co m*/ windowListener.windowClosing(new WindowEvent(mockFrame, WindowEvent.WINDOW_CLOSING)); assertTrue(shutdownApplicationWasCalled); }
From source file:org.ietr.preesm.mapper.ui.BestCostPlotter.java
@Override public void windowClosing(WindowEvent event) { if (event.equals(WindowEvent.WINDOW_CLOSING)) { } }
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/*from www. ja va2 s . c om*/ public void actionPerformed(ActionEvent e) { dispatchEvent(new WindowEvent(ScanProgressDialog.this, WindowEvent.WINDOW_CLOSING)); } }); } return closeButton; }