Example usage for javax.swing JFrame isActive

List of usage examples for javax.swing JFrame isActive

Introduction

In this page you can find the example usage for javax.swing JFrame isActive.

Prototype

public boolean isActive() 

Source Link

Document

Returns whether this Window is active.

Usage

From source file:Main.java

private static void triggerBringToFront(final JFrame f, final int delayMS) {
    Timer timer = new Timer(delayMS, new ActionListener() {
        @Override//from   ww w  .j a  v  a2s .  c o  m
        public void actionPerformed(ActionEvent e) {
            // This will only cause the task bar entry
            // for this frame to blink
            // f.toFront();

            // This will bring the window to the front,
            // but not make it the "active" one
            // f.setAlwaysOnTop(true);
            // f.setAlwaysOnTop(false);

            if (!f.isActive()) {
                f.setState(JFrame.ICONIFIED);
                f.setState(JFrame.NORMAL);
            }
        }
    });
    timer.setRepeats(false);
    timer.start();
}