List of usage examples for java.awt Window pack
@SuppressWarnings("deprecation") public void pack()
From source file:com.jcraft.weirdx.DDXWindowImp.java
public void setVisible(boolean b) { if (b) {//w ww.jav a 2 s .co m if (offi == null && window.clss != InputOnly) { allocImage(); } if (window != window.screen.root && !isVisible()) { exposed.setBounds(0, 0, 0, 0); } super.setVisible(true); if (window.screen.windowmode != WeirdX.InBrowser && window.hasFrame()) { java.awt.Window frame = window.getFrame(); if (frame instanceof java.awt.Frame) { frame.add("Center", this); frame.pack(); synchronized (XWindow.LOCK) { Property p = window.getProperty(); while (p != null) { if (p.propertyName == 39) break; p = p.next; } if (p != null && p.type == 31) { String title = ""; if (p.size > 0) { title = new String(p.data); } ((java.awt.Frame) (frame)).setTitle(title); } } } else { frame.add(this); } frame.validate(); Insets insets = frame.getInsets(); frame.setSize(window.width + window.borderWidth * 2 + insets.left + insets.right, window.height + window.borderWidth * 2 + insets.top + insets.bottom); super.setLocation(insets.left, insets.top); frame.validate(); } } else { if (isVisible()) { super.setVisible(false); if (window != window.screen.root && window.screen.root.width * window.screen.root.height / 4 <= window.width * window.height) { freeImage(); exposed.setBounds(0, 0, 0, 0); } } } }
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 v a 2 s . c o m 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:com.jcraft.weirdx.XWindow.java
XWindow(int wid, XWindow prnt, int x, int y, int width, int height, int bwidth, int clss, byte depth, Client client, int visual, int msk) throws IOException { this(wid);/*from w w w . java 2 s. c om*/ WindowOpt opt; this.client = client; this.parent = prnt; screen = prnt.screen; if (clss == CopyFromParent) clss = prnt.clss; this.clss = clss; if ((clss != InputOutput) && (clss != InputOnly)) { client.errorValue = clss; client.errorReason = 2; // BadValue; return; } if ((clss != InputOnly) && (prnt.clss == InputOnly)) { client.errorValue = clss; client.errorReason = 8; // BadMatch; return; } if ((clss == InputOnly) && ((bwidth != 0) || (depth != 0))) { client.errorValue = 0; client.errorReason = 8; // BadMatch; return; } if ((clss == InputOutput) && (depth == 0)) { depth = prnt.depth; } opt = prnt.optional; if (opt == null) { opt = prnt.findOptional().optional; } if (visual == CopyFromParent) { visual = opt.visual; } if ((visual != opt.visual) || (depth != prnt.depth)) { boolean foo = false; Depth pdepth; for (int i = 0; i < screen.depth.length; i++) { pdepth = screen.depth[i]; if (depth == pdepth.depth || depth == 0) { if (pdepth.visual != null) { for (int j = 0; j < pdepth.visual.length; j++) { if (visual == pdepth.visual[j].id) { foo = true; break; } } } } } if (!foo) { client.errorValue = 0; client.errorReason = 8; // BadMatch; return; } } if (((msk & (CWBorderPixmap | CWBorderPixel)) == 0) && (clss != InputOnly) && (depth != prnt.depth)) { client.errorValue = 0; client.errorReason = 8; // BadMatch; return; } this.depth = depth; if (depth == prnt.depth) { this.bitsPerPixel = prnt.bitsPerPixel; } else { int ii = 0; while (ii < Format.format.length) { if (Format.format[ii].depth == screen.rootDepth) break; ii++; } if (ii == Format.format.length) { // ??? ii = 0; } this.bitsPerPixel = Format.format[ii].bpp; } this.type = prnt.type; if (clss == InputOnly) this.type = UNDRAWABLE_WINDOW; setDefault(); if (visual != opt.visual) { makeOptional(); this.optional.visual = visual; this.optional.colormap = screen.defaultColormap; } this.borderWidth = bwidth; attr &= ~backgroundState; attr &= ~borderIsPixel; attr |= (prnt.attr & borderIsPixel); this.border = prnt.border.dup(); if ((attr & borderIsPixel) == 0) { this.border.pixmap.ref(); } this.origin.x = (short) (x + bwidth); this.origin.y = (short) (y + bwidth); this.width = width; this.height = height; this.x = (short) (prnt.x + x + bwidth); this.y = (short) (prnt.y + y + bwidth); synchronized (LOCK) { this.nextSib = prnt.firstChild; if (prnt.firstChild != null) prnt.firstChild.prevSib = this; else prnt.lastChild = this; prnt.firstChild = this; } if ((msk & CWEventMask) == 0) { recalculateDeliverableEvents(); } msk &= 0x7fff; if (msk != 0) { changeAttr(client, msk); } if (client.errorReason != 0) { this.delete(); return; } if ((msk & CWBackingStore) != 0 && (defaultBackingStore != 0)) { attr &= ~backingStore; attr |= (defaultBackingStore << backingStoreOffset); attr |= forcedBS; } // ddxwindow=new DDXWindow(); try { ddxwindow = (DDXWindow) dDXWindow.newInstance(); } catch (Exception e) { LOG.error(e); /*ddxwindow=new DDXWindow();*/ } ddxwindow.init(this); try { if (screen.windowmode != WeirdX.InBrowser && prnt == screen.root) { final java.awt.Window frame = getFrame(); /* if(frame instanceof JFrame){ ((JFrame)frame).setJMenuBar(null); ((JFrame)frame).getContentPane().setLayout(null); ((JFrame)frame).setResizable(false); } else*/ if (frame instanceof Frame) { ((Frame) frame).setMenuBar(null); ((Frame) frame).setResizable(true); } ddxwindow.setLocation(0, 0); // if(frame instanceof JFrame){ // ((JFrame)frame).getContentPane().add((java.awt.Component)ddxwindow); // } // else{ frame.add((java.awt.Component) ddxwindow); // } frame.pack(); Insets insets = frame.getInsets(); /* frame.setSize(this.width+this.borderWidth*2+ insets.left+insets.right, this.height+this.borderWidth*2+ insets.bottom+insets.top); */ frame.setLocation(this.origin.x - this.borderWidth + parent.borderWidth, this.origin.y - this.borderWidth + parent.borderWidth); if (frame instanceof Frame) { addWindowListener((java.awt.Frame) frame); addComponentListener((java.awt.Frame) frame); } } else { ddxwindow.setLocation(origin.x - borderWidth + parent.borderWidth, origin.y - borderWidth + parent.borderWidth); prnt.ddxwindow.add((java.awt.Component) ddxwindow, 0); } if ((attr & cursorIsNone) == 0) { XCursor cur = getCursor(); if (cur != null) { ddxwindow.setCursor(cur.cursor); } } if (bwidth > 0) { ddxwindow.setBorderPixmap(border.pixmap); } } catch (Exception ee) { //System.out.println("error: Window?? "+ee); } if (prnt.subSend()) { client.cevent.mkCreateNotify(prnt.id, id, x, y, width, height, borderWidth, (attr & overrideRedirect) != 0 ? 0 : 1); prnt.sendEvent(client.cevent, 1, null); } }