Example usage for java.awt Window toBack

List of usage examples for java.awt Window toBack

Introduction

In this page you can find the example usage for java.awt Window 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:corelyzer.ui.CorelyzerApp.java

public void GLWindowsToBack() {
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            for (final Window win : windowVec) {
                win.toBack();
            }//from   w  ww  .j  a v  a  2  s.c o  m
        }
    });
}

From source file:corelyzer.ui.CorelyzerApp.java

/**
 * Called by the DisplayConfiguration dialog class to begin the creation of
 * the OpenGL windows given previously set parameters of rows and columns of
 * monitors, and the properties of each monitor
 *///w  w w . j a  v a2s.  c om
public void createGLWindows() {
    int nrows = preferences.numberOfRows;
    int ncols = preferences.numberOfColumns;
    int tileWidth = preferences.screenWidth;
    int tileHeight = preferences.screenHeight;

    float borderLeft = preferences.borderLeft;
    float borderRight = preferences.borderRight;
    float borderDown = preferences.borderDown;
    float borderUp = preferences.borderUp;

    float screenDpiX = preferences.dpix;
    float screenDpiY = preferences.dpiy;

    int row_offset, column_offset;

    try {
        row_offset = Integer.parseInt(preferences.getProperty("display.row_offset"));
        column_offset = Integer.parseInt(preferences.getProperty("display.column_offset"));
    } catch (NumberFormatException e) {
        row_offset = 0;
        column_offset = 0;
    }

    // brg 1/17/2012: In Windows Vista and 7, Z-order issues with tool windows and the main canvas
    // are abundant and beyond my abilities to fix. We discovered a workaround - reduce the
    // canvas size by a single row/column of pixels, and everything will work properly. Enforce
    // this programatically until we find a fix.
    final String osName = System.getProperty("os.name").toLowerCase();
    final boolean isWindowsCompositingOS = (osName.equals("windows 7") || osName.equals("windows vista"));
    if (isWindowsCompositingOS)
        tileHeight--; // remove one row

    SceneGraph.setCanvasRowcAndColumn(nrows, ncols);

    sharedContext = null;
    int r, c, canvasNum = 0;
    for (r = 0; r < nrows; r++) {
        for (c = 0; c < ncols; c++) {
            // Allow alpha GL context
            GLProfile profile = GLProfile.getDefault();
            GLCapabilities cap = new GLCapabilities(profile);//GLProfile.getDefault() );
            cap.setAlphaBits(8);
            // System.out.println("---> GL " + cap.toString());

            /*
             * if(MAC_OS_X) { win = new JFrame(); ((JFrame)
             * win).setUndecorated(true); } else { win = new JWindow(); }
             */

            Window win = new JFrame();
            ((JFrame) win).setUndecorated(true);

            win.setLocation(c * tileWidth + column_offset, r * tileHeight + row_offset);

            // brg 3/16/2012: Once we have a shared context, it must be passed in the constructor.
            // The setContext() method doesn't work. (JOGL bug?)
            GLCanvas cvs = null;
            if (sharedContext != null)
                cvs = new GLCanvas(cap, null, sharedContext, null);
            else
                cvs = new GLCanvas(cap);

            win.add(cvs);
            win.addWindowFocusListener(new WindowFocusListener() {
                public void windowGainedFocus(final WindowEvent event) {
                    // do nothing
                }

                public void windowLostFocus(final WindowEvent event) {
                    String isCanvasAlwaysBelow = preferences.getProperty("ui.canvas.alwaysBelow");

                    boolean b;
                    try {
                        b = Boolean.parseBoolean(isCanvasAlwaysBelow);
                    } catch (Exception e) {
                        b = true;
                    }

                    if (b) {
                        GLWindowsToBack();
                    }
                }
            });

            canvasNum++;

            windowVec.add(win);

            final float px = tileWidth * c + (borderLeft + borderRight) * screenDpiX * c;
            final float py = tileHeight * r + (borderUp + borderDown) * screenDpiY * r;
            final int id = SceneGraph.genCanvas(px, py, tileWidth, tileHeight, screenDpiX, screenDpiY);

            CorelyzerGLCanvas cglc = new CorelyzerGLCanvas(cvs, tileWidth, tileHeight, px, py, id);
            canvasVec.add(cglc);

            // if it's the bottom most screen or the first column,
            // then mark to draw depth scale
            if (c == 0) {
                SceneGraph.setCanvasFirstColumn(cglc.getCanvasID(), true);
            }

            if (r == nrows - 1) {
                SceneGraph.setCanvasBottomRow(cglc.getCanvasID(), true);
            }

            win.pack();
            win.setVisible(true);

            // brg 3/16/2012: In JOGL2, a GLCanvas's context is only usable after the
            // canvas has been made visible. Grab the context from the first canvas
            // and share with subsequent canvases at construction-time.
            if (sharedContext == null)
                sharedContext = cvs.getContext();

            win.toBack();
        }
    }

    createTrackMenuItem.setEnabled(true);
    loadDataMenuItem.setEnabled(true);
    loadStateFileMenuItem.setEnabled(true);

    isGLInited = true;
}

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

/**
 * Prepares {@link Component} for printing.
 * //from  w w w .  j  a  va  2 s  . c o m
 * 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);
        }
    }
}