List of usage examples for java.awt Frame pack
@SuppressWarnings("deprecation") public void pack()
From source file:com.jcraft.weirdx.XWindow.java
private void addComponentListener(java.awt.Frame foo) { final java.awt.Frame frame = foo; frame.addComponentListener(new java.awt.event.ComponentAdapter() { public void componentResized(java.awt.event.ComponentEvent e) { if (parent == null) return; Rectangle rectangle = frame.getBounds(); if (rectangle.width == 0 || rectangle.height == 0) return; if (frame_width != rectangle.width || frame_height != rectangle.height) { Insets insets = frame.getInsets(); synchronized (XWindow.LOCK) { try { Point point = frame.getLocation(); int ww = rectangle.width - insets.left - insets.right - borderWidth * 2; int hh = rectangle.height - insets.top - insets.bottom - borderWidth * 2; if (ww > 0 && hh > 0) { ddxwindow.setSize(ww, hh); frame.pack(); Event event = new Event(); event.mkConfigureNotify(id, id, (rectangle.x + insets.left), (rectangle.y + insets.top), ww, hh, borderWidth, (attr & (1 << 16)) != 0 ? 1 : 0); sendEvent(event, 1, null); frame_x = rectangle.x; frame_y = rectangle.y; frame_width = rectangle.width; frame_height = rectangle.height; }/*from ww w . j ava2 s.co m*/ } catch (Exception ee) { LOG.error(ee); } } } } }); }
From source file:org.geoserver.wms.WMSTestSupport.java
/** * Shows <code>image</code> in a Frame. * /* w w w . ja va 2 s . c o m*/ * @param frameName * @param timeOut * @param image */ public static void showImage(String frameName, long timeOut, final BufferedImage image) { int width = image.getWidth(); int height = image.getHeight(); if (((System.getProperty("java.awt.headless") == null) || !System.getProperty("java.awt.headless").equals("true")) && INTERACTIVE) { Frame frame = new Frame(frameName); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { e.getWindow().dispose(); } }); Panel p = new Panel(null) { // no layout manager so it respects // setSize public void paint(Graphics g) { g.drawImage(image, 0, 0, this); } }; frame.add(p); p.setSize(width, height); frame.pack(); frame.setVisible(true); try { Thread.sleep(timeOut); } catch (InterruptedException e) { e.printStackTrace(); } frame.dispose(); } }
From source file:org.opensc.test.pkcs11.PINEntry.java
/** * Contructs a PINEntry instance. /*from w ww. j a v a2 s . c o m*/ */ public PINEntry() { super(); Frame frame = new Frame("PIN entry"); frame.setLayout(new GridLayout(2, 2)); frame.add(new Label("Event:")); this.label = new Label("NO_EVENT"); frame.add(this.label); this.prompt = new Label(); frame.add(this.prompt); this.listener = new PINListener(frame); this.textField = new TextField(); this.textField.setEchoChar('*'); this.textField.addKeyListener(this.listener); frame.add(this.textField); frame.addWindowListener(this.listener); frame.pack(); frame.setVisible(true); GraphicsConfiguration gc = frame.getGraphicsConfiguration(); Rectangle r = gc.getBounds(); Point p = new Point((r.width - frame.getWidth()) / 2, (r.height - frame.getHeight()) / 2); frame.setLocation(p); }