private static void saveWindowPosition(Frame frame) { if (!isWindowPositioningEnabled()) { return; } Point point; try { point = frame.getLocationOnScreen(); } catch (Exception e) { e.printStackTrace(); try { point = frame.getLocation(); } catch (Exception e2) { e2.printStackTrace(); return; } } int x = (int)point.getX(); int y = (int)point.getY(); int w = frame.getWidth(); int h = frame.getHeight(); Utils.setConfigInteger("window.x", x); Utils.setConfigInteger("window.y", y); Utils.setConfigInteger("window.w", w); Utils.setConfigInteger("window.h", h); LOGGER.debug("Saved window position (x=" + x + ", y=" + y + ", w=" + w + ", h=" + h + ")"); }
private boolean isGeneric() { if (_parent == null) { return false; } return (_parent.getWidth() == 1 && _parent.getHeight() == 1); }
private Dimension get getFrameToScreenRatio(Frame aFrame){ Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize(); return dimension.setSize(aFrame.getWidth()/dimension.getWidth(), aFrame.getHeight()/dimension.getHeight()); }
boolean frameLayoutCompleted() { final Frame frame = JOptionPane.getFrameForComponent(this); final Insets frameInsets = frame.getInsets(); final Component rootPane = frame.getComponent(0); final boolean frameLayoutCompleted = rootPane.getWidth() == frame.getWidth() - frameInsets.left - frameInsets.right && rootPane.getHeight() == frame.getHeight() - frameInsets.top - frameInsets.bottom; return frameLayoutCompleted; }
public void setVisible(boolean visible) { if (visible) { setLocation((int) frame.getLocation().getX() + (frame.getWidth() / 2) - (getWidth() / 2), (int) frame.getLocation().getY() + (frame.getHeight() / 2) - (getHeight() / 2)); } super.setVisible(visible); }
PopupRequestResponseDialog(IHttpRequestResponse requestResponse, IBurpExtenderCallbacks callbacks, Container parent, String title) { this.requestResponse = requestResponse; Frame parentFrame = JOptionPane.getFrameForComponent(parent); JDialog dialog = new JDialog(parentFrame, title); requestEditor = callbacks.createMessageEditor(this, false); requestEditor.setMessage(requestResponse.getRequest(), true); responseEditor = callbacks.createMessageEditor(this, false); responseEditor.setMessage(requestResponse.getResponse(), false); JTabbedPane tabs = new JTabbedPane(); tabs.add("Request", requestEditor.getComponent()); tabs.add("Response", responseEditor.getComponent()); dialog.getContentPane().add(tabs); dialog.setSize(Math.min(800,parentFrame.getWidth()/2),Math.min(600, parentFrame.getHeight()/2)); //dialog.setLocationRelativeTo(parentFrame); dialog.setLocation(parentFrame.getWidth()/2 - dialog.getWidth()/2 + parentFrame.getX(), parentFrame.getHeight()/2 - dialog.getHeight()/2 + parentFrame.getY()); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); }
public AboutFrame(Frame parent) { super(parent, Messages.getString("Viz.About", "Ontopia Vizigator"), true); JPanel mainPanel = new JPanel(); mainPanel.setBackground(Color.white); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); mainPanel.add(createImagePanel()); mainPanel.add(createAboutTextPanel()); this.getContentPane().add(mainPanel); this.pack(); this.setResizable(false); // Center the dialog box above its parent this.setLocation( (parent.getX() + (parent.getWidth() - this.getWidth()) / 2), parent .getY() + (parent.getHeight() - this.getHeight()) / 2); }
public void run() { GraphicsConfiguration gc = frame.getGraphicsConfiguration(); Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc); Rectangle maxBounds = gc.getBounds(); maxBounds.width -= (screenInsets.left + screenInsets.right); maxBounds.height -= (screenInsets.top + screenInsets.bottom); if ((frame.getWidth() != maxBounds.width) || (frame.getHeight() != maxBounds.height)) { restore(); wasMaximizeError = true; frame.setMaximizedBounds(null); maximize(); } } });
/** Center on the specified frame. */ public static void centerOnFrame(Window window, Frame frame) { int ww = window.getWidth(); int wh = window.getHeight(); int fw = frame.getWidth(); int fh = frame.getHeight(); int x = (int)Math.round((double)(fw - ww) / 2); int y = (int)Math.round((double)(fh - wh) / 2); Point location = frame.getLocationOnScreen(); location.translate(x, y); window.setLocation(location); ensureOnScreen(window); }
private static void resizePopup() { popupWindow.pack(); Point point = new Point(0, 0); SwingUtilities.convertPointToScreen(point, getMainWindow()); popupWindow.setLocation(point.x + (getMainWindow().getWidth() - popupWindow.getWidth()) / 2, point.y + (getMainWindow().getHeight() - popupWindow.getHeight()) / 3); } private static final int X_INSET = 10;
private static void resizePopup() { popupWindow.pack(); Point point = new Point(0,0); SwingUtilities.convertPointToScreen(point, getMainWindow()); popupWindow.setLocation( point.x + (getMainWindow().getWidth() - popupWindow.getWidth()) / 2, point.y + (getMainWindow().getHeight() - popupWindow.getHeight()) / 3); }
private static void resizePopup() { popupWindow.pack(); Point point = new Point(0,0); SwingUtilities.convertPointToScreen(point, getMainWindow()); popupWindow.setLocation( point.x + (getMainWindow().getWidth() - popupWindow.getWidth()) / 2, point.y + (getMainWindow().getHeight() - popupWindow.getHeight()) / 3); }
private static void resizePopup() { popupWindow.pack(); Point point = new Point(0, 0); SwingUtilities.convertPointToScreen(point, getMainWindow()); popupWindow.setLocation(point.x + (getMainWindow().getWidth() - popupWindow.getWidth()) / 2, point.y + (getMainWindow().getHeight() - popupWindow.getHeight()) / 3); } private static final int X_INSET = 10;
private static void resizePopup() { popupWindow.pack(); Point point = new Point(0, 0); SwingUtilities.convertPointToScreen(point, getMainWindow()); popupWindow.setLocation(point.x + (getMainWindow().getWidth() - popupWindow.getWidth()) / 2, point.y + (getMainWindow().getHeight() - popupWindow.getHeight()) / 3); }
private static void resizePopup() { popupWindow.pack(); Point point = new Point(0,0); SwingUtilities.convertPointToScreen(point, getMainWindow()); popupWindow.setLocation( point.x + (getMainWindow().getWidth() - popupWindow.getWidth()) / 2, point.y + (getMainWindow().getHeight() - popupWindow.getHeight()) / 3); }
@Test public void checkBug35PanelWithVariableHeightChild() throws Exception { // Show in default size checkExample(Bug35PanelWithVariableHeightChild.class); // Problem: resize vertically frame().resizeHeightTo(frame().component().getHeight() + 50); checkSnapshot("after-resize"); }
@Test public void checkBug36SmartVerticalResize() throws Exception { launchGui(SmartVerticalResize4RealWorldExample.class); checkSnapshot("bug36-pref-size"); frame().moveTo(new Point(frame().target.getX(), 0)); for (int i = 1; i <= BUG36_STEPS; i++) { frame().resizeHeightTo(frame().target.getHeight() + BUG36_INCREMENT); checkSnapshot("bug36-resize-" + (i * BUG36_INCREMENT)); } for (int i = 1; i <= BUG36_STEPS; i++) { frame().resizeHeightTo(frame().target.getHeight() - BUG36_INCREMENT); checkSnapshot("bug36-reverse-" + (i * BUG36_INCREMENT)); } }
@Test public void checkSpanRowsOnCustomComponent() throws Exception { launchGui(RowSpan7SpecialComponent.class); checkSnapshot("pref-size"); frame().moveTo(new Point(frame().target.getX(), 0)); Dimension size = new Dimension( frame().target.getWidth(), frame().target.getHeight()); for (int i = 1; i <= 5; i++) { size.width += 6; size.height += 9; frame().resizeTo(size); checkSnapshot("resize-" + i); } }
final protected void checkExampleAndResizeHeight( Class<? extends IExample> clazz, int increment, int steps) throws Exception { launchGui(clazz); checkSnapshot("pref-size"); frame().moveTo(new Point(frame().target.getX(), 0)); for (int i = 1; i <= steps; i++) { frame().resizeHeightTo(frame().target.getHeight() + increment); checkSnapshot("resize-" + (i * increment)); } }
final private void hideMouse() { Frame frame = _frame.component(); _robot.moveMouse(frame, frame.getWidth() + 2, 0); _robot.waitForIdle(); _robot.moveMouse(frame, frame.getWidth() + 2, frame.getHeight() + 2); _robot.waitForIdle(); }