Example usage for java.awt Window requestFocus

List of usage examples for java.awt Window requestFocus

Introduction

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

Prototype

public void requestFocus() 

Source Link

Document

Requests that this Component get the input focus, and that this Component's top-level ancestor become the focused Window.

Usage

From source file:org.pgptool.gui.ui.tools.UiUtils.java

/**
 * Hack to make sure window is visible. On windows it's sometimes created but on
 * a background. User can see "flashing" icon in a task bar but window stays on
 * a background.//w  w  w . java2s.  co m
 * 
 * PRESUMING: setVisible(true) was already called
 * 
 * More ion tihs jere:
 * http://stackoverflow.com/questions/309023/how-to-bring-a-window-to-the-front
 */
public static void makeSureWindowBroughtToFront(Window window) {
    // int state = dialog.getExtendedState();
    // state &= ~JFrame.ICONIFIED;
    // dialog.setExtendedState(state);
    window.setAlwaysOnTop(true);
    window.toFront();
    window.requestFocus();
    window.setAlwaysOnTop(false);
    window.repaint();
}