Java Code Examples for java.awt.event.WindowEvent
The following examples show how to use
java.awt.event.WindowEvent. These examples are extracted from open source projects.
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 Project: Pushjet-Android Source File: Application.java License: BSD 2-Clause "Simplified" License | 6 votes |
private void setupUI() { frame = new JFrame("Gradle"); JPanel mainPanel = new JPanel(new BorderLayout()); frame.getContentPane().add(mainPanel); mainPanel.add(singlePaneUIInstance.getComponent()); mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); singlePaneUIInstance.aboutToShow(); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { close(); } }); frame.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); frame.setLocationByPlatform(true); }
Example 2
Source Project: CQL Source File: JFontChooser.java License: GNU Affero General Public License v3.0 | 6 votes |
/** * Show font selection dialog. * * @param parent Dialog's Parent component. * @return OK_OPTION, CANCEL_OPTION or ERROR_OPTION * * @see #OK_OPTION * @see #CANCEL_OPTION * @see #ERROR_OPTION **/ public int showDialog(Component parent) { dialogResultValue = ERROR_OPTION; JDialog dialog = createDialog(parent); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { dialogResultValue = CANCEL_OPTION; } }); dialog.setVisible(true); dialog.dispose(); dialog = null; return dialogResultValue; }
Example 3
Source Project: openjdk-jdk9 Source File: JFrame.java License: GNU General Public License v2.0 | 6 votes |
/** * Processes window events occurring on this component. * Hides the window or disposes of it, as specified by the setting * of the <code>defaultCloseOperation</code> property. * * @param e the window event * @see #setDefaultCloseOperation * @see java.awt.Window#processWindowEvent */ protected void processWindowEvent(final WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { switch (defaultCloseOperation) { case HIDE_ON_CLOSE: setVisible(false); break; case DISPOSE_ON_CLOSE: dispose(); break; case EXIT_ON_CLOSE: // This needs to match the checkExit call in // setDefaultCloseOperation System.exit(0); break; case DO_NOTHING_ON_CLOSE: default: } } }
Example 4
Source Project: openjdk-jdk9 Source File: Util.java License: GNU General Public License v2.0 | 6 votes |
private static boolean trackEvent(int eventID, Component comp, Runnable action, int time, boolean printEvent) { EventListener listener = null; switch (eventID) { case WindowEvent.WINDOW_GAINED_FOCUS: listener = wgfListener; break; case FocusEvent.FOCUS_GAINED: listener = fgListener; break; case ActionEvent.ACTION_PERFORMED: listener = apListener; break; } listener.listen(comp, printEvent); action.run(); return Util.waitForCondition(listener.getNotifier(), time); }
Example 5
Source Project: MeteoInfo Source File: MapLayout.java License: GNU Lesser General Public License v3.0 | 6 votes |
/** * Show measurment form */ public void showMeasurementForm() { if (_frmMeasure == null) { _frmMeasure = new FrmMeasurement((JFrame) SwingUtilities.getWindowAncestor(this), false); _frmMeasure.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { _currentLayoutMap.getMapFrame().getMapView().setDrawIdentiferShape(false); //repaint(); repaintOld(); } }); _frmMeasure.setLocationRelativeTo(this); _frmMeasure.setVisible(true); } else if (!_frmMeasure.isVisible()) { _frmMeasure.setVisible(true); } }
Example 6
Source Project: amidst Source File: ProfileSelectWindow.java License: GNU General Public License v3.0 | 6 votes |
@CalledOnlyBy(AmidstThread.EDT) private JFrame createFrame() { JFrame frame = new JFrame("Profile Selector"); frame.setIconImages(metadata.getIcons()); frame.getContentPane().setLayout(new MigLayout()); frame.add(createTitleLabel(), "h 20!,w :400:, growx, pushx, wrap"); frame.add(createScrollPanel(), getScrollPaneLayoutString()); frame.pack(); frame.addKeyListener(profileSelectPanel.createKeyListener()); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { application.exitGracefully(); } }); frame.setLocation(200, 200); frame.setVisible(true); return frame; }
Example 7
Source Project: Digital Source File: NumberingWizard.java License: GNU General Public License v3.0 | 6 votes |
/** * Creates a new instance * * @param parent the parent frame * @param circuitComponent the component used to select the inputs and outputs */ public NumberingWizard(JFrame parent, CircuitComponent circuitComponent) { super(parent, Lang.get("msg_numberingWizard"), false); setDefaultCloseOperation(DISPOSE_ON_CLOSE); this.circuitComponent = circuitComponent; label = new JLabel(); label.setFont(Screen.getInstance().getFont(1.5f)); int b = Screen.getInstance().getFontSize(); label.setBorder(BorderFactory.createEmptyBorder(b, b, b, b)); setPinNumber(999); getContentPane().add(label); addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent windowEvent) { circuitComponent.deactivateWizard(); } }); pack(); pinNumber = 1; setPinNumber(pinNumber); setLocation(parent.getLocation()); }
Example 8
Source Project: java-swing-tips Source File: MainPanel.java License: MIT License | 6 votes |
@Override public void actionPerformed(ActionEvent e) { Component root; Container parent = SwingUtilities.getUnwrappedParent((Component) e.getSource()); if (parent instanceof JPopupMenu) { JPopupMenu popup = (JPopupMenu) parent; root = SwingUtilities.getRoot(popup.getInvoker()); } else if (parent instanceof JToolBar) { JToolBar toolbar = (JToolBar) parent; if (((BasicToolBarUI) toolbar.getUI()).isFloating()) { root = SwingUtilities.getWindowAncestor(toolbar).getOwner(); } else { root = SwingUtilities.getRoot(toolbar); } } else { root = SwingUtilities.getRoot(parent); } if (root instanceof Window) { Window window = (Window) root; window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING)); } }
Example 9
Source Project: consulo Source File: DesktopIdeFrameImpl.java License: Apache License 2.0 | 6 votes |
private void setupCloseAction() { myJFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); myJFrame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(@Nonnull final WindowEvent e) { if (isTemporaryDisposed()) return; final Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); if (openProjects.length > 1 || openProjects.length == 1 && TopApplicationMenuUtil.isMacSystemMenu) { if (myProject != null && myProject.isOpen()) { ProjectUtil.closeAndDispose(myProject); } ApplicationManager.getApplication().getMessageBus().syncPublisher(AppLifecycleListener.TOPIC).projectFrameClosed(); WelcomeFrame.showIfNoProjectOpened(); } else { Application.get().exit(); } } }); }
Example 10
Source Project: jdk8u60 Source File: Font2DTest.java License: GNU General Public License v2.0 | 6 votes |
private void loadComparisonPNG( String fileName ) { try { BufferedImage image = javax.imageio.ImageIO.read(new File(fileName)); JFrame f = new JFrame( "Comparison PNG" ); ImagePanel ip = new ImagePanel( image ); f.setResizable( false ); f.getContentPane().add( ip ); f.addWindowListener( new WindowAdapter() { public void windowClosing( WindowEvent e ) { ( (JFrame) e.getSource() ).dispose(); } }); f.pack(); f.show(); } catch ( Exception ex ) { fireChangeStatus( "ERROR: Failed to Load PNG File; See Stack Trace", true ); ex.printStackTrace(); } }
Example 11
Source Project: openjdk-jdk9 Source File: EditPad.java License: GNU General Public License v2.0 | 6 votes |
@Override public void run() { JFrame jframe = new JFrame(windowLabel == null ? getResourceString("editpad.name") : windowLabel); Runnable closer = () -> { jframe.setVisible(false); jframe.dispose(); closeMark.run(); }; jframe.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { closer.run(); } }); jframe.setLocationRelativeTo(null); jframe.setLayout(new BorderLayout()); JTextArea textArea = new JTextArea(initialText); textArea.setFont(new Font("monospaced", Font.PLAIN, 13)); jframe.add(new JScrollPane(textArea), BorderLayout.CENTER); jframe.add(buttons(closer, textArea), BorderLayout.SOUTH); jframe.setSize(800, 600); jframe.setVisible(true); }
Example 12
Source Project: IBC Source File: StopTask.java License: GNU General Public License v3.0 | 5 votes |
private void stop() { JFrame jf = MainWindowManager.mainWindowManager().getMainWindow(); WindowEvent wev = new WindowEvent(jf, WindowEvent.WINDOW_CLOSING); Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(wev); writeAck("Shutting down"); }
Example 13
Source Project: openjdk-jdk8u-backup Source File: TargetFileListFrame.java License: GNU General Public License v2.0 | 5 votes |
private void initGUI(Point location) { this.setLocation(location); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { TargetFileListFrame.this.dispose(); } }); this.add(new Panel().add(list)); this.pack(); this.setVisible(true); }
Example 14
Source Project: netbeans Source File: EditableDisplayerTest.java License: Apache License 2.0 | 5 votes |
public void windowOpened(WindowEvent e) { shown = true; synchronized(this) { //System.err.println("window opened"); notifyAll(); ((JFrame) e.getSource()).removeWindowListener(this); } }
Example 15
Source Project: rapidminer-studio Source File: SettingsDialog.java License: GNU Affero General Public License v3.0 | 5 votes |
/** * Sets up the related {@link SettingsTabs} and buttons for the Studio settings. This uses {@link #getDefaultStudioHandler()} * and {@link SettingsItems#INSTANCE} for initialization. * * Selects the specified selected tab. * * @param initialSelectedTab * A key of a preferences group to identify the initial selected tab. */ public SettingsDialog(String initialSelectedTab) { this(getDefaultStudioHandler(), SettingsItems.INSTANCE, initialSelectedTab); // add listener to remove parameter handler when dialog is closed addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { parameterHandler.getParameters().getParameterTypes().stream() .flatMap(pt -> pt.getConditions().stream()).forEach(pc -> pc.setParameterHandler(null)); } }); }
Example 16
Source Project: openjdk-jdk9 Source File: ContainerFocusAutoTransferTest.java License: GNU General Public License v2.0 | 5 votes |
public void init() { robot = Util.createRobot(); kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { public void eventDispatched(AWTEvent event) { System.out.println("--> " + event); } }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK); }
Example 17
Source Project: IBC Source File: AbstractLoginHandler.java License: GNU General Public License v3.0 | 5 votes |
@Override public boolean filterEvent(Window window, int eventId) { switch (eventId) { case WindowEvent.WINDOW_OPENED: return true; default: return false; } }
Example 18
Source Project: openjdk-8 Source File: TargetFileListFrame.java License: GNU General Public License v2.0 | 5 votes |
private void initGUI(Point location) { this.setLocation(location); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { TargetFileListFrame.this.dispose(); } }); this.add(new Panel().add(list)); this.pack(); this.setVisible(true); }
Example 19
Source Project: bigtable-sql Source File: FileViewerFactory.java License: Apache License 2.0 | 5 votes |
/** * Viewer has been closed so allow it to be garbage collected. */ // public void internalFrameClosed(InternalFrameEvent evt) public void windowClosed(WindowEvent evt) { // removeViewer((HtmlViewerSheet)evt.getInternalFrame()); removeViewer((HtmlViewerSheet)evt.getWindow()); // super.internalFrameClosed(evt); }
Example 20
Source Project: IBC Source File: NonBrokerageAccountDialogHandler.java License: GNU General Public License v3.0 | 5 votes |
@Override public boolean filterEvent(Window window, int eventId) { switch (eventId) { case WindowEvent.WINDOW_OPENED: return true; default: return false; } }
Example 21
Source Project: TencentKona-8 Source File: MultimonFullscreenTest.java License: 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 22
Source Project: netbeans Source File: CustomizerProviderImpl.java License: Apache License 2.0 | 5 votes |
public void windowClosing( WindowEvent e ) { //Dispose the dialog otherwsie the {@link WindowAdapter#windowClosed} //may not be called Dialog dialog = (Dialog)project2Dialog.get( project ); if ( dialog != null ) { dialog.setVisible(false); dialog.dispose(); } }
Example 23
Source Project: jdk8u-jdk Source File: ContainerFocusAutoTransferTest.java License: GNU General Public License v2.0 | 5 votes |
public void init() { robot = Util.createRobot(); kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() { public void eventDispatched(AWTEvent event) { System.out.println("--> " + event); } }, FocusEvent.FOCUS_EVENT_MASK | WindowEvent.WINDOW_FOCUS_EVENT_MASK); }
Example 24
Source Project: dragonwell8_jdk Source File: SunToolkit.java License: GNU General Public License v2.0 | 5 votes |
public static void postEvent(AppContext appContext, AWTEvent event) { if (event == null) { throw new NullPointerException(); } AWTAccessor.SequencedEventAccessor sea = AWTAccessor.getSequencedEventAccessor(); if (sea != null && sea.isSequencedEvent(event)) { AWTEvent nested = sea.getNested(event); if (nested.getID() == WindowEvent.WINDOW_LOST_FOCUS && nested instanceof TimedWindowEvent) { TimedWindowEvent twe = (TimedWindowEvent)nested; ((SunToolkit)Toolkit.getDefaultToolkit()). setWindowDeactivationTime((Window)twe.getSource(), twe.getWhen()); } } // All events posted via this method are system-generated. // Placing the following call here reduces considerably the // number of places throughout the toolkit that would // otherwise have to be modified to precisely identify // system-generated events. setSystemGenerated(event); AppContext eventContext = targetToAppContext(event.getSource()); if (eventContext != null && !eventContext.equals(appContext)) { throw new RuntimeException("Event posted on wrong app context : " + event); } PostEventQueue postEventQueue = (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY); if (postEventQueue != null) { postEventQueue.postEvent(event); } }
Example 25
Source Project: mylizzie Source File: ByoYomiAutoPlayDialog.java License: GNU General Public License v3.0 | 5 votes |
private void thisWindowClosing(WindowEvent e) { countdownSystemStop(); stopCountdown(); Lizzie.board.unregisterBoardStateChangeObserver(boardStateChangeObserver); OptionSetting.ByoYomiSetting byoYomiSetting = Lizzie.optionSetting.getByoYomiSetting(); byoYomiSetting.setByoYomiTime((Integer) spinnerCountdownTime.getValue()); byoYomiSetting.setStopThinkingWhenCountingDown(checkBoxStopThinkingWhenCountDown.isSelected()); }
Example 26
Source Project: TrakEM2 Source File: FilePathRepair.java License: GNU General Public License v3.0 | 5 votes |
private final Runnable makeGUI() { return new Runnable() { public void run() { JScrollPane jsp = new JScrollPane(table); jsp.setPreferredSize(new Dimension(500, 500)); table.addMouseListener(listener); JLabel label = new JLabel("Double-click any to repair file path:"); JLabel label2 = new JLabel("(Any listed with identical parent folder will be fixed as well.)"); JPanel plabel = new JPanel(); BoxLayout pbl = new BoxLayout(plabel, BoxLayout.Y_AXIS); plabel.setLayout(pbl); //plabel.setBorder(new LineBorder(Color.black, 1, true)); plabel.setMinimumSize(new Dimension(400, 40)); plabel.add(label); plabel.add(label2); JPanel all = new JPanel(); BoxLayout bl = new BoxLayout(all, BoxLayout.Y_AXIS); all.setLayout(bl); all.add(plabel); all.add(jsp); frame.getContentPane().add(all); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { synchronized (projects) { if (data.vpath.size() > 0 ) { Utils.logAll("WARNING: Some images remain associated to inexistent file paths."); } projects.remove(project); } } }); frame.pack(); ij.gui.GUI.center(frame); frame.setVisible(true); }}; }
Example 27
Source Project: netbeans Source File: ProjectCustomizerProvider.java License: Apache License 2.0 | 5 votes |
@Override public void windowClosing (WindowEvent e) { //Dispose the dialog otherwsie the {@link WindowAdapter#windowClosed} //may not be called Dialog dialog = project2Dialog.get( project ); if ( dialog != null ) { dialog.setVisible(false); dialog.dispose(); } }
Example 28
Source Project: aifh Source File: ElementaryCA.java License: Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void windowActivated(WindowEvent arg0) { // TODO Auto-generated method stub }
Example 29
Source Project: MikuMikuStudio Source File: MaterialBrowser.java License: BSD 2-Clause "Simplified" License | 4 votes |
public void windowClosed(WindowEvent e) { }
Example 30
Source Project: JDKSourceCode1.8 Source File: PopupFactory.java License: MIT License | 4 votes |
/** * Recycles the passed in <code>HeavyWeightPopup</code>. */ private static void recycleHeavyWeightPopup(HeavyWeightPopup popup) { synchronized (HeavyWeightPopup.class) { List<HeavyWeightPopup> cache; Window window = SwingUtilities.getWindowAncestor( popup.getComponent()); Map<Window, List<HeavyWeightPopup>> heavyPopupCache = getHeavyWeightPopupCache(); if (window instanceof Popup.DefaultFrame || !window.isVisible()) { // If the Window isn't visible, we don't cache it as we // likely won't ever get a windowClosed event to clean up. // We also don't cache DefaultFrames as this indicates // there wasn't a valid Window parent, and thus we don't // know when to clean up. popup._dispose(); return; } else if (heavyPopupCache.containsKey(window)) { cache = heavyPopupCache.get(window); } else { cache = new ArrayList<HeavyWeightPopup>(); heavyPopupCache.put(window, cache); // Clean up if the Window is closed final Window w = window; w.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { List<HeavyWeightPopup> popups; synchronized(HeavyWeightPopup.class) { Map<Window, List<HeavyWeightPopup>> heavyPopupCache2 = getHeavyWeightPopupCache(); popups = heavyPopupCache2.remove(w); } if (popups != null) { for (int counter = popups.size() - 1; counter >= 0; counter--) { popups.get(counter)._dispose(); } } } }); } if(cache.size() < MAX_CACHE_SIZE) { cache.add(popup); } else { popup._dispose(); } } }