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:com.adobe.aem.demomachine.gui.AemDemoUtils.java
public static void installEscapeCloseOperation(final JDialog dialog) { Action dispatchClosing = new AbstractAction() { private static final long serialVersionUID = 1L; public void actionPerformed(ActionEvent event) { dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING)); }//from w w w . ja v a 2 s . c om }; JRootPane root = dialog.getRootPane(); root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(escapeStroke, dispatchWindowClosingActionMapKey); root.getActionMap().put(dispatchWindowClosingActionMapKey, dispatchClosing); }
From source file:jgnash.ui.commodity.SecuritiesHistoryDialog.java
@Override public void actionPerformed(final ActionEvent e) { if (e.getSource() == applyButton) { addNode();/* w ww .ja v a 2 s . c om*/ } else if (e.getSource() == clearButton) { clearForm(); } else if (e.getSource() == deleteButton) { removeNode(); } else if (e.getSource() == updateButton) { netAddNode(); } else if (e.getSource() == securityCombo) { changeNode(); } else if (e.getSource() == closeButton) { dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING)); } }
From source file:studio.ui.Studio.java
@Override protected void processWindowEvent(WindowEvent event) { switch (event.getID()) { case WindowEvent.WINDOW_CLOSING: if (tabEditors != null && tabEditors.getTabCount() > 0) { int current = tabEditors.getSelectedIndex(); boolean close = true; for (int count = 0; close & count < tabEditors.getTabCount(); count++) { Editor editor = tabEditors.getEditor(count); if (editor != null) { if (editor.getFile() != null) { editor.getFile().setActive(count == current); }/*from w w w . ja v a2 s . c om*/ if (editor.isModified() && !editor.isEmpty()) { tabEditors.setSelectedIndex(count); close &= tabEditors.closeEditor(editor); } } } if (!close) { tabEditors.setSelectedIndex(current); tabEditors.getEditor(current).requestFocus(); return; } else { for (int count = 0; count < tabEditors.getTabCount(); count++) { if (tabEditors.getEditor(count) != null) { tabEditors.getEditor(count).setModified(false); } } } } java.util.List<EditorFile> files = tabEditors.saveFiles(); if (files == null) { return; } try { studioConfig.setLastFiles(files); } catch (ConfigException ex) { ex.printStackTrace(); } super.processWindowEvent(event); System.exit(0); break; case WindowEvent.WINDOW_ACTIVATED: if (tabEditors != null && tabEditors.getTabCount() > 0 && tabEditors.getEditor() != null) { tabEditors.getEditor().requestFocusInWindow(); } break; } super.processWindowEvent(event); }
From source file:com.limegroup.gnutella.gui.GUIUtils.java
/** * Returns (possibly constructing) the ESC action. *///from www .j a va 2 s.co m public static Action getDisposeAction() { if (ACTION_DISPOSE == null) { ACTION_DISPOSE = new AbstractAction() { /** * */ private static final long serialVersionUID = 3219036624812939826L; public void actionPerformed(ActionEvent ae) { Window parent; if (ae.getSource() instanceof Window) parent = (Window) ae.getSource(); else parent = SwingUtilities.getWindowAncestor((Component) ae.getSource()); if (parent != null) parent.dispatchEvent(new WindowEvent(parent, WindowEvent.WINDOW_CLOSING)); } }; } return ACTION_DISPOSE; }
From source file:com.moneydance.modules.features.mdvenmoimporter.VenmoImporterWindow.java
public final void processEvent(AWTEvent evt) { if (evt.getID() == WindowEvent.WINDOW_CLOSING) { extension.closeConsole();// w w w. j a v a 2 s. c o m return; } if (evt.getID() == WindowEvent.WINDOW_OPENED) { } super.processEvent(evt); }
From source file:ee.ioc.cs.vsle.editor.Editor.java
/** * Overridden so we can exit when window is closed * /*from www . j a va 2s .c om*/ * @param e - Window Event. */ @Override protected void processWindowEvent(WindowEvent e) { // super.processWindowEvent(e); // automatic closing disabled, // confirmation asked instead. if (e.getID() == WindowEvent.WINDOW_CLOSING) { exitApplication(); } else { super.processWindowEvent(e); } }
From source file:com.sldeditor.test.unit.tool.vector.VectorToolTest.java
/** * Test method for {@link com.sldeditor.tool.vector.VectorTool#VectorTool(com.sldeditor.common.SLDEditorInterface)}. */// w w w . ja v a 2 s .co m @Test public void testVectorToolFileDataSource() { TestMissingSLDAttributes testAttribute = new TestMissingSLDAttributes(); List<CheckAttributeInterface> checkList = new ArrayList<CheckAttributeInterface>(); checkList.add(testAttribute); CheckAttributeFactory.setOverideCheckList(checkList); String testsldfile = "/polygon/sld/polygon_polygonwithdefaultlabel.sld"; TestSLDEditor testSLDEditor = null; try { testSLDEditor = TestSLDEditor.createAndShowGUI2(null, null, true, null); } catch (Exception e) { e.printStackTrace(); } InputStream inputStream = VectorToolTest.class.getResourceAsStream(testsldfile); if (inputStream == null) { Assert.assertNotNull("Failed to find sld test file : " + testsldfile, inputStream); } else { File f = null; try { f = stream2file(inputStream); try { testSLDEditor.openFile(f.toURI().toURL()); } catch (NullPointerException nullException) { nullException.printStackTrace(); StackTraceElement[] stackTraceElements = nullException.getStackTrace(); System.out.println(stackTraceElements[0].getMethodName()); } f.delete(); } catch (IOException e1) { e1.printStackTrace(); } } // Fields extracted from the SLD file DataSourceInterface dataSource = DataSourceFactory.createDataSource(null); Collection<PropertyDescriptor> propertyList = dataSource.getPropertyDescriptorList(); assertEquals(2, propertyList.size()); Map<String, PropertyDescriptor> map = new HashMap<String, PropertyDescriptor>(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } AttributeDescriptor name = (AttributeDescriptor) map.get("name"); assertNotNull(name); GeometryDescriptor geometry = (GeometryDescriptor) map.get("geom"); assertNotNull(geometry); File tempFolder = Files.createTempDir(); TestVectorTool vectorTool = new TestVectorTool(testSLDEditor); try { // Set a shape file as a data source - that matches the SLD File matchingShpFile = extractShapeFile(tempFolder, "/test/sld_cookbook_polygon.zip"); FileTreeNode fileTreeNode = new FileTreeNode(matchingShpFile.getParentFile(), matchingShpFile.getName()); vectorTool.testSetDataSource(fileTreeNode); dataSource = DataSourceFactory.createDataSource(null); propertyList = dataSource.getPropertyDescriptorList(); assertEquals(3, propertyList.size()); map.clear(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } name = (AttributeDescriptor) map.get("name"); assertNotNull(name); geometry = (GeometryDescriptor) map.get("the_geom"); assertNotNull(geometry); AttributeDescriptor pop = (AttributeDescriptor) map.get("pop"); assertNotNull(pop); // Set a shape file as a data source - that does not match the SLD File nonMatchingShpFile = extractShapeFile(tempFolder, "/test/states.zip"); FileTreeNode fileTreeNode2 = new FileTreeNode(nonMatchingShpFile.getParentFile(), nonMatchingShpFile.getName()); vectorTool.testSetDataSource(fileTreeNode2); dataSource = DataSourceFactory.createDataSource(null); propertyList = dataSource.getPropertyDescriptorList(); assertEquals(23, propertyList.size()); map.clear(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } name = (AttributeDescriptor) map.get("name"); assertNull(name); geometry = (GeometryDescriptor) map.get("the_geom"); assertNotNull(geometry); pop = (AttributeDescriptor) map.get("pop"); assertNull(pop); assertEquals(1, testAttribute.getMissingFieldList().size()); assertEquals("name", testAttribute.getMissingFieldList().get(0)); // Create SLD from shape file vectorTool.testImportFile(fileTreeNode); dataSource = DataSourceFactory.createDataSource(null); propertyList = dataSource.getPropertyDescriptorList(); assertEquals(3, propertyList.size()); map.clear(); for (PropertyDescriptor property : propertyList) { map.put(property.getName().getLocalPart(), property); } name = (AttributeDescriptor) map.get("name"); assertNotNull(name); geometry = (GeometryDescriptor) map.get("the_geom"); assertNotNull(geometry); pop = (AttributeDescriptor) map.get("pop"); assertNotNull(pop); // Release locks dataSource.reset(); } catch (IOException e) { e.printStackTrace(); fail(); } // Tidy up so the remaining unit tests are ok JFrame frame = testSLDEditor.getApplicationFrame(); frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING)); testSLDEditor = null; clearDown(); // Delete the shape files we extracted purgeDirectory(tempFolder); }
From source file:org.ash.gui.MainFrame.java
@Override protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { menuFileExit_actionPerformed(null); }/* w w w . ja va2 s.c o m*/ }
From source file:com.qawaa.gui.EventWebScanGUI.java
@Override protected void processWindowEvent(WindowEvent e) { if (e.getID() == WindowEvent.WINDOW_CLOSING) { this.windowsClosed(); }//from www . j av a2 s . c om //super.processWindowEvent(e); }
From source file:br.upe.ecomp.dosa.view.wizard.WizardAction.java
private void closeDialog() { dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING)); }