Java Code Examples for java.awt.Window#dispose()
The following examples show how to use
java.awt.Window#dispose() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BackgroundIsNotUpdated.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws AWTException { final Window window = new BackgroundIsNotUpdated(null); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); sleep(); window.setBackground(Color.GREEN); sleep(); final Robot robot = new Robot(); robot.setAutoDelay(200); Point point = window.getLocationOnScreen(); Color color = robot.getPixelColor(point.x + window.getWidth() / 2, point.y + window.getHeight() / 2); window.dispose(); if (!color.equals(Color.GREEN)) { throw new RuntimeException( "Expected: " + Color.GREEN + " , Actual: " + color); } }
Example 2
Source File: BackgroundIsNotUpdated.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws AWTException { final Window window = new BackgroundIsNotUpdated(null); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); sleep(); window.setBackground(Color.GREEN); sleep(); final Robot robot = new Robot(); robot.setAutoDelay(200); Point point = window.getLocationOnScreen(); Color color = robot.getPixelColor(point.x + window.getWidth() / 2, point.y + window.getHeight() / 2); window.dispose(); if (!color.equals(Color.GREEN)) { throw new RuntimeException( "Expected: " + Color.GREEN + " , Actual: " + color); } }
Example 3
Source File: BackgroundIsNotUpdated.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(final String[] args) throws AWTException { final Window window = new BackgroundIsNotUpdated(null); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); sleep(); window.setBackground(Color.GREEN); sleep(); final Robot robot = new Robot(); robot.setAutoDelay(200); Point point = window.getLocationOnScreen(); Color color = robot.getPixelColor(point.x + window.getWidth() / 2, point.y + window.getHeight() / 2); window.dispose(); if (!color.equals(Color.GREEN)) { throw new RuntimeException( "Expected: " + Color.GREEN + " , Actual: " + color); } }
Example 4
Source File: MultimonFullscreenTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public void windowClosing(WindowEvent we) { done = true; Window w = (Window)we.getSource(); if (setNullOnDispose) { w.getGraphicsConfiguration().getDevice().setFullScreenWindow(null); } w.dispose(); }
Example 5
Source File: UnionEditorProviderTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testCloseEditorAndCancel() throws Exception { Window dialog; init(complexUnion, pgmTestCat, false); // Change the union. Swing.runLater(() -> { delete(4, 5); try { model.add(new WordDataType()); } catch (UsrException e) { Assert.fail(e.getMessage()); } }); waitForTasks(); DataType newDt = model.viewComposite.clone(null); assertFalse(complexUnion.isEquivalent(model.viewComposite)); Swing.runLater(() -> provider.closeComponent()); waitForSwing(); dialog = waitForWindow("Save Union Editor Changes?"); assertNotNull(dialog); pressButton(dialog, "Cancel"); dialog.dispose(); dialog = null; assertTrue(tool.isVisible(provider)); assertFalse(complexUnion.isEquivalent(model.viewComposite)); assertTrue(newDt.isEquivalent(model.viewComposite)); }
Example 6
Source File: UnionEditorProviderTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testCloseEditorAndNoSave() throws Exception { Window dialog; init(complexUnion, pgmTestCat, false); DataType oldDt = model.viewComposite.clone(null); // Change the union. Swing.runLater(() -> { delete(4, 5); try { model.add(new WordDataType()); } catch (UsrException e) { Assert.fail(e.getMessage()); } }); waitForTasks(); DataType newDt = model.viewComposite.clone(null); assertFalse(complexUnion.isEquivalent(model.viewComposite)); assertTrue(complexUnion.isEquivalent(oldDt)); Swing.runLater(() -> provider.closeComponent()); waitForSwing(); dialog = waitForWindow("Save Union Editor Changes?"); assertNotNull(dialog); pressButton(dialog, "Yes"); dialog.dispose(); dialog = null; assertFalse(tool.isVisible(provider)); assertTrue(complexUnion.isEquivalent(newDt)); assertFalse(complexUnion.isEquivalent(oldDt)); }
Example 7
Source File: StructureEditorNotifiedTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testModifiedEditedDataTypeReplacedNo() throws Exception { Window dialog; init(complexStructure, pgmTestCat); runSwing(() -> { try { // model.setLocked(false); model.insert(model.getNumComponents(), new ByteDataType(), 1); model.insert(model.getNumComponents(), new PointerDataType(), 4); } catch (UsrException e) { Assert.fail(e.getMessage()); } }); DataType viewCopy = model.viewComposite.clone(null); final Structure newComplexStructure = new StructureDataType(pgmTestCat.getCategoryPath(), complexStructure.getName(), 0); newComplexStructure.add(new PointerDataType(), 8); newComplexStructure.add(new CharDataType(), 1); programDTM.replaceDataType(complexStructure, newComplexStructure, true); waitForPostedSwingRunnables(); // Verify the Reload Structure Editor? dialog is displayed. dialog = env.waitForWindow("Reload Structure Editor?", 1000); assertNotNull(dialog); pressButtonByText(dialog, "No"); dialog.dispose(); dialog = null; assertEquals(((Structure) viewCopy).getNumComponents(), model.getNumComponents()); assertTrue(viewCopy.isEquivalent(model.viewComposite)); }
Example 8
Source File: UIManager.java From sagetv with Apache License 2.0 | 5 votes |
void hideWindow(Window hideMe) { if (getDisposeWindows()) hideMe.dispose(); else hideMe.setVisible(false); }
Example 9
Source File: UnionEditorNotifiedTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testModifiedEditedDataTypeReplacedYes() throws Exception { Window dialog; try { init(complexUnion, pgmTestCat, false); runSwing(() -> { try { model.insert(model.getNumComponents(), new ByteDataType(), 1); model.insert(model.getNumComponents(), new PointerDataType(), 4); } catch (UsrException e) { Assert.fail(e.getMessage()); } }); final Union newComplexUnion = new UnionDataType(pgmTestCat.getCategoryPath(), complexUnion.getName()); newComplexUnion.add(new PointerDataType(), 8); newComplexUnion.add(new CharDataType(), 1); programDTM.replaceDataType(complexUnion, newComplexUnion, true); waitForSwing(); DataType origCopy = newComplexUnion.clone(null); // Verify the Reload Union Editor? dialog is displayed. dialog = env.waitForWindow("Reload Union Editor?", 1000); assertNotNull(dialog); pressButtonByText(dialog, "Yes"); dialog.dispose(); dialog = null; assertEquals(((Union) origCopy).getNumComponents(), model.getNumComponents()); assertTrue(origCopy.isEquivalent(model.viewComposite)); } finally { dialog = null; cleanup(); } }
Example 10
Source File: EventLogPopup.java From arcusplatform with Apache License 2.0 | 5 votes |
@Override protected boolean disposeComponent(Window component) { component.setVisible(false); component.dispose(); this.log.dispose(); return true; }
Example 11
Source File: MultimonFullscreenTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public void windowClosing(WindowEvent we) { done = true; Window w = (Window)we.getSource(); if (setNullOnDispose) { w.getGraphicsConfiguration().getDevice().setFullScreenWindow(null); } w.dispose(); }
Example 12
Source File: PreviewPane.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
private void closeToolbar() { if ( toolBar == null ) { return; } if ( toolBar.getParent() != toolbarHolder ) { // ha!, we detected that the toolbar is floating ... // Log.debug (currentToolbar.getParent()); final Window w = SwingUtilities.windowForComponent( toolBar ); if ( w != null ) { w.setVisible( false ); w.dispose(); } } toolBar.setVisible( false ); }
Example 13
Source File: LocationByPlatformTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { Window window = new Window(null); window.setSize(100, 100); window.setLocationByPlatform(true); if (!window.isLocationByPlatform()) { throw new RuntimeException("Location by platform is not set"); } window.setLocation(10, 10); if (window.isLocationByPlatform()) { throw new RuntimeException("Location by platform is not cleared"); } window.setLocationByPlatform(true); window.setBounds(20, 20, 50, 50); if (window.isLocationByPlatform()) { throw new RuntimeException("Location by platform is not cleared"); } window.setLocationByPlatform(true); window.setVisible(false); if (window.isLocationByPlatform()) { throw new RuntimeException("Location by platform is not cleared"); } window.setLocationByPlatform(true); window.setVisible(true); if (window.isLocationByPlatform()) { throw new RuntimeException("Location by platform is not cleared"); } window.dispose(); }
Example 14
Source File: MultimonFullscreenTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public void windowClosing(WindowEvent we) { done = true; Window w = (Window)we.getSource(); if (setNullOnDispose) { w.getGraphicsConfiguration().getDevice().setFullScreenWindow(null); } w.dispose(); }
Example 15
Source File: UnionEditorNotifiedTest.java From ghidra with Apache License 2.0 | 5 votes |
@Test public void testModifiedEditedDataTypeChangedYes() throws Exception { Window dialog; try { init(complexUnion, pgmTestCat, false); runSwing(() -> { try { model.insert(model.getNumComponents(), new ByteDataType(), 1); model.insert(model.getNumComponents(), new PointerDataType(), 4); } catch (UsrException e) { Assert.fail(e.getMessage()); } }); SwingUtilities.invokeLater(() -> complexUnion.add(new CharDataType())); waitForSwing(); DataType origCopy = complexUnion.clone(null); // Verify the Reload Union Editor? dialog is displayed. dialog = env.waitForWindow("Reload Union Editor?", 1000); assertNotNull(dialog); pressButtonByText(dialog, "Yes"); dialog.dispose(); dialog = null; waitForSwing(); assertEquals(((Union) origCopy).getNumComponents(), model.getNumComponents()); assertTrue(origCopy.isEquivalent(model.viewComposite)); } finally { dialog = null; cleanup(); } }
Example 16
Source File: MainFrame.java From scelight with Apache License 2.0 | 4 votes |
/** * Builds the menu bar of the main frame. */ private void buildToolBar() { final XToolBar toolBar = new XToolBar(); cp.addNorth( toolBar ); toolBar.add( Actions.SETTINGS ); toolBar.addSeparator(); toolBar.add( Actions.OPEN_REPLAY ); toolBar.add( Actions.QUICK_OPEN_LAST_REP ); toolBar.add( new HelpIcon( Helps.QUICK_OPEN_LAST_REPLAY ) ); toolBar.addSeparator(); toolBar.add( Actions.START_SC2 ); toolBar.addSeparator(); toolBar.add( Actions.HOME_PAGE ); toolBar.add( Actions.ABOUT_ABOUT ); toolBar.addSeparator(); toolBar.add( new XLabel( LSettings.SKILL_LEVEL.name + ":" ) ); toolBar.add( SettingsGui.createSkillLevelComboBox( null ) ); toolBar.add( new HelpIcon( LHelps.COMP_SKILL_LEVEL ) ); toolBar.addSeparator(); toolBar.add( new XLabel( LHelps.HELP_LEGEND.title ) ); toolBar.add( new HelpIcon( LHelps.HELP_LEGEND ).leftBorder( 2 ) ); toolBar.finalizeLayout(); // Bind floating and displaying to setting final ISettingChangeListener scl = new ISettingChangeListener() { @Override public void valuesChanged( final ISettingChangeEvent event ) { // BUG: If a floating tool bar (detached) is changed not to be floatable and is closed after that, // it disappears (doesn't get docked back to the main frame). // To prevent this, we always dock back the tool bar if it is made hidden or not floatable. if ( event.affectedAny( Settings.MAIN_TOOL_BAR_FLOTABLE, Settings.SHOW_MAIN_TOOL_BAR ) ) { if ( !event.get( Settings.MAIN_TOOL_BAR_FLOTABLE ) || !event.get( Settings.SHOW_MAIN_TOOL_BAR ) ) { final Window parentWindow = SwingUtilities.getWindowAncestor( toolBar ); if ( parentWindow != null && !MainFrame.this.equals( parentWindow ) ) { // Is it floating now? parentWindow.dispose(); // Reset orientation because we attach it to north toolBar.setOrientation( SwingConstants.HORIZONTAL ); cp.addNorth( toolBar ); } } } if ( event.affected( Settings.MAIN_TOOL_BAR_FLOTABLE ) ) toolBar.setFloatable( event.get( Settings.MAIN_TOOL_BAR_FLOTABLE ) ); if ( event.affected( Settings.SHOW_MAIN_TOOL_BAR ) ) toolBar.setVisible( event.get( Settings.SHOW_MAIN_TOOL_BAR ) ); } }; final Set< Setting< ? > > listendSettingSet = Utils.< Setting< ? > > asNewSet( Settings.MAIN_TOOL_BAR_FLOTABLE, Settings.SHOW_MAIN_TOOL_BAR ); SettingsGui.addBindExecuteScl( scl, Env.APP_SETTINGS, listendSettingSet, toolBar ); }
Example 17
Source File: JFontChooser.java From hortonmachine with GNU General Public License v3.0 | 4 votes |
public void componentHidden(ComponentEvent e) { Window w = (Window) e.getComponent(); w.dispose(); }
Example 18
Source File: FullScreenInsets.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 19
Source File: FullScreenInsets.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }
Example 20
Source File: FullScreenInsets.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
public static void main(final String[] args) { final GraphicsEnvironment ge = GraphicsEnvironment .getLocalGraphicsEnvironment(); final GraphicsDevice[] devices = ge.getScreenDevices(); final Window wGreen = new Frame(); wGreen.setBackground(Color.GREEN); wGreen.setSize(300, 300); wGreen.setVisible(true); sleep(); final Insets iGreen = wGreen.getInsets(); final Dimension sGreen = wGreen.getSize(); final Window wRed = new Frame(); wRed.setBackground(Color.RED); wRed.setSize(300, 300); wRed.setVisible(true); sleep(); final Insets iRed = wGreen.getInsets(); final Dimension sRed = wGreen.getSize(); for (final GraphicsDevice device : devices) { if (!device.isFullScreenSupported()) { continue; } device.setFullScreenWindow(wGreen); sleep(); testWindowBounds(device.getDisplayMode(), wGreen); testColor(wGreen, Color.GREEN); device.setFullScreenWindow(wRed); sleep(); testWindowBounds(device.getDisplayMode(), wRed); testColor(wRed, Color.RED); device.setFullScreenWindow(null); sleep(); testInsets(wGreen.getInsets(), iGreen); testInsets(wRed.getInsets(), iRed); testSize(wGreen.getSize(), sGreen); testSize(wRed.getSize(), sRed); } wGreen.dispose(); wRed.dispose(); if (!passed) { throw new RuntimeException("Test failed"); } }