Example usage for javax.swing JFrame toBack

List of usage examples for javax.swing JFrame toBack

Introduction

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

Prototype

public void toBack() 

Source Link

Document

If this Window is visible, sends this Window to the back and may cause it to lose focus or activation if it is the focused or active Window.

Usage

From source file:net.chaosserver.timelord.swingui.CommonTaskPanel.java

/**
 * Hides the application window out of site and mind on Win and Mac.
 *//*from   w w w . j  av a2s.  c o m*/
protected void hideFrame() {
    JFrame frame = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, this);
    frame.toBack();

    // Use reflection for compile-time avoidance.
    try {
        Class<?> nsApplicationClass = Class.forName("com.apple.cocoa.application.NSApplication");
        Method sharedAppMethod = nsApplicationClass.getDeclaredMethod("sharedApplication", new Class<?>[] {});

        Object nsApplicationObject = sharedAppMethod.invoke(null, new Object[] {});

        /*
        Field userAttentionRequestCriticalField =
        nsApplicationClass.getDeclaredField(
            "UserAttentionRequestCritical");
        */

        Method hideMethod = nsApplicationClass.getDeclaredMethod("hide", new Class[] { Object.class });

        hideMethod.invoke(nsApplicationObject, new Object[] { nsApplicationObject });
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.debug("Issue bouncing dock", e);
        }
    }
}