public void showIt(boolean centered) { if(centered) { RefineryUtilities.centerFrameOnScreen(this); } showIt(); }
/** * Shows / updates the displayed graph. */ public void showMe() { boolean shown; synchronized(this) { shown = isShown; if (!isShown) { isShown = true; } } if(!shown) { this.pack(); RefineryUtilities.centerFrameOnScreen(this); RefineryUtilities.positionFrameRandomly(this); RefineryUtilities.positionFrameOnScreen(this, 1, 0); this.setVisible(true); } }
/** * Positions the specified dialog within its parent. * * @param dialog the dialog to be positioned on the screen. */ public static void centerDialogInParent(final Dialog dialog) { positionDialogRelativeToParent(dialog, 0.5, 0.5); }
/** * Positions the specified frame in the middle of the screen. * * @param frame the frame to be centered on the screen. */ public static void centerFrameOnScreen(final Window frame) { positionFrameOnScreen(frame, 0.5, 0.5); }
final JLabel appLabel = RefineryUtilities.createJLabel(application, f1, Color.black); appLabel.setHorizontalTextPosition(SwingConstants.CENTER); appPanel.add(appLabel); final JLabel verLabel = RefineryUtilities.createJLabel(version, f2, Color.black); verLabel.setHorizontalTextPosition(SwingConstants.CENTER); verPanel.add(verLabel); final JLabel copyrightLabel = RefineryUtilities.createJLabel(copyright, f2, Color.black); copyrightLabel.setHorizontalTextPosition(SwingConstants.CENTER); copyrightPanel.add(copyrightLabel); final JLabel infoLabel = RefineryUtilities.createJLabel(info, f2, Color.black); infoLabel.setHorizontalTextPosition(SwingConstants.CENTER); infoPanel.add(infoLabel);
/** * Positions the specified frame at a relative position in the screen, where 50% is considered * to be the center of the screen. * * @param frame the frame. * @param horizontalPercent the relative horizontal position of the frame (0.0 to 1.0, * where 0.5 is the center of the screen). * @param verticalPercent the relative vertical position of the frame (0.0 to 1.0, where * 0.5 is the center of the screen). */ public static void positionFrameOnScreen(final Window frame, final double horizontalPercent, final double verticalPercent) { final Rectangle s = getMaximumWindowBounds(); final Dimension f = frame.getSize(); final int w = Math.max(s.width - f.width, 0); final int h = Math.max(s.height - f.height, 0); final int x = (int) (horizontalPercent * w) + s.x; final int y = (int) (verticalPercent * h) + s.y; frame.setBounds(x, y, f.width, f.height); }
/** * Positions the specified frame in the middle of the screen. * * @param frame the frame to be centered on the screen. */ public static void centerFrameOnScreen(final Window frame) { positionFrameOnScreen(frame, 0.5, 0.5); }
final JLabel appLabel = RefineryUtilities.createJLabel(application, f1, Color.black); appLabel.setHorizontalTextPosition(SwingConstants.CENTER); appPanel.add(appLabel); final JLabel verLabel = RefineryUtilities.createJLabel(version, f2, Color.black); verLabel.setHorizontalTextPosition(SwingConstants.CENTER); verPanel.add(verLabel); final JLabel copyrightLabel = RefineryUtilities.createJLabel(copyright, f2, Color.black); copyrightLabel.setHorizontalTextPosition(SwingConstants.CENTER); copyrightPanel.add(copyrightLabel); final JLabel infoLabel = RefineryUtilities.createJLabel(info, f2, Color.black); infoLabel.setHorizontalTextPosition(SwingConstants.CENTER); infoPanel.add(infoLabel);
/** * Positions the specified frame at a relative position in the screen, where 50% is considered * to be the center of the screen. * * @param frame the frame. * @param horizontalPercent the relative horizontal position of the frame (0.0 to 1.0, * where 0.5 is the center of the screen). * @param verticalPercent the relative vertical position of the frame (0.0 to 1.0, where * 0.5 is the center of the screen). */ public static void positionFrameOnScreen(final Window frame, final double horizontalPercent, final double verticalPercent) { final Rectangle s = getMaximumWindowBounds(); final Dimension f = frame.getSize(); final int w = Math.max(s.width - f.width, 0); final int h = Math.max(s.height - f.height, 0); final int x = (int) (horizontalPercent * w) + s.x; final int y = (int) (verticalPercent * h) + s.y; frame.setBounds(x, y, f.width, f.height); }
public void showIt(boolean centered) { if(centered) { RefineryUtilities.centerFrameOnScreen(this); } showIt(); }
RefineryUtilities.centerFrameOnScreen(demo); RefineryUtilities.positionFrameRandomly(demo); RefineryUtilities.positionFrameOnScreen(demo, 1, 0); if (visible) { demo.setVisible(true);
/** * Positions the specified frame in the middle of the screen. * * @param frame the frame to be centered on the screen. */ public static void centerFrameOnScreen(final Window frame) { positionFrameOnScreen(frame, 0.5, 0.5); }
/** * Positions the specified dialog within its parent. * * @param dialog the dialog to be positioned on the screen. */ public static void centerDialogInParent(final Dialog dialog) { positionDialogRelativeToParent(dialog, 0.5, 0.5); }
final JLabel appLabel = RefineryUtilities.createJLabel(application, f1, Color.black); appLabel.setHorizontalTextPosition(SwingConstants.CENTER); appPanel.add(appLabel); final JLabel verLabel = RefineryUtilities.createJLabel(version, f2, Color.black); verLabel.setHorizontalTextPosition(SwingConstants.CENTER); verPanel.add(verLabel); final JLabel copyrightLabel = RefineryUtilities.createJLabel(copyright, f2, Color.black); copyrightLabel.setHorizontalTextPosition(SwingConstants.CENTER); copyrightPanel.add(copyrightLabel); final JLabel infoLabel = RefineryUtilities.createJLabel(info, f2, Color.black); infoLabel.setHorizontalTextPosition(SwingConstants.CENTER); infoPanel.add(infoLabel);
/** * Positions the specified dialog at a position relative to its parent. * * @param dialog the dialog to be positioned. * @param horizontalPercent the relative location. * @param verticalPercent the relative location. */ public static void positionDialogRelativeToParent(final Dialog dialog, final double horizontalPercent, final double verticalPercent) { final Dimension d = dialog.getSize(); final Container parent = dialog.getParent(); final Dimension p = parent.getSize(); final int baseX = parent.getX() - d.width; final int baseY = parent.getY() - d.height; final int w = d.width + p.width; final int h = d.height + p.height; int x = baseX + (int) (horizontalPercent * w); int y = baseY + (int) (verticalPercent * h); // make sure the dialog fits completely on the screen... final Rectangle s = getMaximumWindowBounds(); x = Math.min(x, (s.width - d.width)); x = Math.max(x, 0); y = Math.min(y, (s.height - d.height)); y = Math.max(y, 0); dialog.setBounds(x + s.x, y + s.y, d.width, d.height); }
public static void main(String[] args) { List<Double> costTrends = Arrays.asList(1.0, 1.2, 1.3, 1.34, 1.23, 1.11, 1.5); CostTrend chart = new CostTrend(costTrends, "cost vs generation"); RefineryUtilities.centerFrameOnScreen( chart ); chart.showIt(true); } }
/** * Positions the specified frame at a random location on the screen while ensuring that the * entire frame is visible (provided that the frame is smaller than the screen). * * @param frame the frame. */ public static void positionFrameRandomly(final Window frame) { positionFrameOnScreen(frame, Math.random(), Math.random()); }
/** * Positions the specified dialog within its parent. * * @param dialog the dialog to be positioned on the screen. */ public static void centerDialogInParent(final Dialog dialog) { positionDialogRelativeToParent(dialog, 0.5, 0.5); }
/** * Positions the specified dialog at a position relative to its parent. * * @param dialog the dialog to be positioned. * @param horizontalPercent the relative location. * @param verticalPercent the relative location. */ public static void positionDialogRelativeToParent(final Dialog dialog, final double horizontalPercent, final double verticalPercent) { final Dimension d = dialog.getSize(); final Container parent = dialog.getParent(); final Dimension p = parent.getSize(); final int baseX = parent.getX() - d.width; final int baseY = parent.getY() - d.height; final int w = d.width + p.width; final int h = d.height + p.height; int x = baseX + (int) (horizontalPercent * w); int y = baseY + (int) (verticalPercent * h); // make sure the dialog fits completely on the screen... final Rectangle s = getMaximumWindowBounds(); x = Math.min(x, (s.width - d.width)); x = Math.max(x, 0); y = Math.min(y, (s.height - d.height)); y = Math.max(y, 0); dialog.setBounds(x + s.x, y + s.y, d.width, d.height); }
public void showWindow() { pack(); RefineryUtilities.centerFrameOnScreen(this); setVisible(true); }