List of usage examples for java.awt Window addWindowFocusListener
public synchronized void addWindowFocusListener(WindowFocusListener l)
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 *//*from w ww.j a va 2 s . com*/ 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; }