Example usage for java.awt Window setFocusableWindowState

List of usage examples for java.awt Window setFocusableWindowState

Introduction

In this page you can find the example usage for java.awt Window setFocusableWindowState.

Prototype

public void setFocusableWindowState(boolean focusableWindowState) 

Source Link

Document

Sets whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow .

Usage

From source file:org.eclipse.wb.internal.swing.utils.SwingImageUtils.java

/**
 * Prepares {@link Component} for printing.
 * //from  w  w w.jav  a  2  s  . c om
 * mitin_aa: Linux: for Metacity window manager (as recommended to use with the Designer) to
 * prevent preview window flickering a better place for preview window is right-bottom screen
 * direction.
 * 
 * TODO: add a preference (Linux only) allowing the user to explicitly set preview window location
 */
public static void prepareForPrinting(Component component) throws Exception {
    component.setLocation(10000, 10000);
    // don't grab focus during printing
    if (component instanceof Window) {
        Window window = (Window) component;
        m_fosucableStates.put(window, window.getFocusableWindowState());
        window.setFocusableWindowState(false);
    }
    // make visible
    setVisible(component, true);
    {
        // workaround to prevent window from flashing if the Window Manager 
        // doesn't allow the window to appear off-screen. 
        if (component instanceof Window) {
            Window window = (Window) component;
            window.toBack();
            // do the location change once again, because sometimes setLocation() 
            // for invisible windows could be ignored.
            component.setLocation(10000, 10000);
        }
    }
}

From source file:org.eclipse.wb.internal.swing.utils.SwingImageUtils.java

/**
 * Disposes given Window with trying to restore it's focusable state.
 *///from   w  w  w  .  java 2 s .  c o m
public static void disposeWindow(final Window window) throws Exception {
    SwingUtils.runLaterAndWait(new RunnableEx() {
        public void run() throws Exception {
            // restore focusable state
            Boolean focusable = m_fosucableStates.get(window);
            if (focusable == null) {
                focusable = true;
            }
            window.setFocusableWindowState(focusable);
            window.dispose();
        }
    });
}