Java Code Examples for java.awt.event.WindowEvent#getWindow()

The following examples show how to use java.awt.event.WindowEvent#getWindow() . 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: DefaultWindowController.java    From lnk2pwn with MIT License 6 votes vote down vote up
@Override
public void eventDispatched(AWTEvent event) {
    if (event instanceof WindowEvent) {
        WindowEvent windowEvent = (WindowEvent) event;
        
        switch(windowEvent.getID())
        {
            case WindowEvent.WINDOW_ACTIVATED:
                window = windowEvent.getWindow();
                break;
                
            case WindowEvent.WINDOW_DEACTIVATED:
                window = null;
                break;
                
            default:
                break;
        }
        
    }
}
 
Example 2
Source File: DefaultApplicationFrame.java    From opt4j with MIT License 5 votes vote down vote up
@Override
public void startup() {
	WindowListener exitListener = new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			Window window = e.getWindow();
			window.setVisible(false);
			window.dispose();
			try {
				Thread.sleep(1000);
			} catch (InterruptedException ignore) {
			} finally {
				System.exit(0);
			}
		}
	};
	addWindowListener(exitListener);

	setIconImage(Icons.getIcon(Icons.OPT4J).getImage());
	setTitle(title);
	setLayout(new BorderLayout());
	JSeparator jSeparator = new JSeparator();

	JPanel toolBarPanel = new JPanel(new BorderLayout());
	toolBarPanel.add(toolBar, BorderLayout.CENTER);
	toolBarPanel.add(jSeparator, BorderLayout.SOUTH);

	add(toolBarPanel, BorderLayout.NORTH);
	add(contentPanel, BorderLayout.CENTER);

	setJMenuBar(menu);

	menu.startup();
	toolBar.startup();
	contentPanel.startup();

	pack();
	setVisible(true);
}
 
Example 3
Source File: ZOrderManager.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void windowActivated(WindowEvent e) {
    logger.entering(getClass().getName(), "windowActivated");

    WeakReference<RootPaneContainer> ww = getWeak((RootPaneContainer)e.getWindow());
    if (ww != null) {
        // place as last item in zOrder list
        zOrder.remove(ww);
        zOrder.add(ww);
    } else {
        throw new IllegalArgumentException("Window not attached: " + e.getWindow()); //NOI18N
    }
}
 
Example 4
Source File: ApplicationFrame.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Listens for the main window closing, and shuts down the application.
 *
 * @param event  information about the window event.
 */
public void windowClosing(final WindowEvent event) {
    if (event.getWindow() == this) {
        dispose();
        System.exit(0);
    }
}
 
Example 5
Source File: BaseWindow.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void windowGainedFocus(WindowEvent event) {
    if (event.getWindow() == this) {
        WINDOW_LIST.remove(this);
        WINDOW_LIST.add(0, this);
    }
}
 
Example 6
Source File: WindowChoreographer.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void windowClosed(WindowEvent e) {
	Window closedWindow = e.getWindow();
	Integer freePosition = windowPosition.remove(closedWindow);
	closedWindow.removeWindowListener(closeListener);
	// Mark as free
	if (freePosition != null) {
		freeSpaces.add(freePosition);
		cleanUp();
	}
}
 
Example 7
Source File: LifecycleBackend.java    From raccoon4 with Apache License 2.0 5 votes vote down vote up
@Override
public void windowClosing(WindowEvent e) {
	if (lifecycleManager.getWindow() == e.getWindow()) {
		// Primary window closed -> Application shutdown
		lifecycleManager.shutdown();
	}
	else {
		// Secondary window closed -> Hide and potentially recycle.
		e.getWindow().setVisible(false);
	}
}
 
Example 8
Source File: ApplicationFrame.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Listens for the main window closing, and shuts down the application.
 *
 * @param event  information about the window event.
 */
public void windowClosing(WindowEvent event) {
    if (event.getWindow() == this) {
        dispose();
        System.exit(0);
    }
}
 
Example 9
Source File: ApplicationFrame.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Listens for the main window closing, and shuts down the application.
 *
 * @param event  information about the window event.
 */
public void windowClosing(WindowEvent event) {
    if (event.getWindow() == this) {
        dispose();
        System.exit(0);
    }
}
 
Example 10
Source File: Configuration.java    From wpcleaner with Apache License 2.0 4 votes vote down vote up
@Override
public void windowClosing(WindowEvent e) {
  if ((e != null) && (e.getWindow() != null)) {
    saveWindowPosition(e.getWindow());
  }
}
 
Example 11
Source File: JFontChooser.java    From hortonmachine with GNU General Public License v3.0 4 votes vote down vote up
public void windowClosing(WindowEvent e) {
    Window w = e.getWindow();
    w.setVisible(false);
}
 
Example 12
Source File: Histogram.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void windowClosing( final WindowEvent evt )
{
	if( evt.getWindow() == this )
		dispose();
}