final JDialog d = new JDialog(); d.setSize(200, 200); final Toolkit toolkit = Toolkit.getDefaultToolkit(); final Dimension screenSize = toolkit.getScreenSize(); final int x = (screenSize.width - d.getWidth()) / 2; final int y = (screenSize.height - d.getHeight()) / 2; d.setLocation(x, y); d.setVisible(true);
private Point findScreenCenter(JDialog dialog) { Toolkit toolkit = Toolkit.getDefaultToolkit(); int x = toolkit.getScreenSize().width / 2 - dialog.getHeight() / 2; int y = toolkit.getScreenSize().height / 2 - dialog.getWidth() / 2; return new Point(x, y); } }
/** * Description of the Method * * @param frame PARAM */ public static void center(JDialog frame) { //p("centering"); Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((int) ((screen_size.getWidth() - frame.getWidth()) / 2), (int) ((screen_size.getHeight() - frame.getHeight()) / 2)); }
/** * Description of the Method * * @param frame PARAM */ public static void center(JDialog frame) { //p("centering"); Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((int) ((screen_size.getWidth() - frame.getWidth()) / 2), (int) ((screen_size.getHeight() - frame.getHeight()) / 2)); }
/** * Description of the Method * * @param frame PARAM */ public static void center(JDialog frame) { //p("centering"); Dimension screen_size = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((int) ((screen_size.getWidth() - frame.getWidth()) / 2), (int) ((screen_size.getHeight() - frame.getHeight()) / 2)); }
private static Point fitToScreen( int x, int y, int altHeight ) { Rectangle screen = org.openide.util.Utilities.getUsableScreenBounds(); Point p = new Point( x, y ); // Adjust the x postition if necessary if ( ( p.x + popupWindow.getWidth() ) > ( screen.x + screen.width - X_INSET ) ) { p.x = screen.x + screen.width - X_INSET - popupWindow.getWidth(); } // Adjust the y position if necessary if ( ( p.y + popupWindow.getHeight() ) > ( screen.y + screen.height - X_INSET ) ) { p.y = p.y - popupWindow.getHeight() - altHeight; } return p; }
public void run() { if (!window.isVisible()) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); taskLabel.setText(message); cancelledAction.setEnabled(true); window.setLocation(screenSize.width / 2 - window.getWidth() / 2, screenSize.height / 2 - window.getHeight() / 2); window.setVisible(true); } } });
public void run() { if (!window.isVisible()) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); window.setLocation(screenSize.width / 2 - window.getWidth() / 2, screenSize.height / 2 - window.getHeight() / 2); window.setVisible(true); } } });
public void rememberFrom(JDialog dialog) { location = dialog.getLocation(); width = dialog.getWidth(); height = dialog.getHeight(); }
public void offset(int offset) { GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); Rectangle bounds = env.getMaximumWindowBounds(); int x = bounds.width - frame.getWidth() - 5; int y = bounds.height - frame.getHeight() - 5 - (frame.getHeight() + 5) * offset; frame.setLocation(x, y); } public void show() {
@Override public void setVisible(boolean visible) { if (!isVisible()) setLocation(parent.getX() + parent.getWidth(), parent.getY()); super.setVisible(visible); }
public static void setDialogLocationUnder(final JDialog dialog, final NodeModel node) { final Controller controller = Controller.getCurrentController(); final IMapViewManager viewController = controller.getMapViewManager(); final JComponent c = (JComponent) viewController.getComponent(node); final int x = 0; final int y = c.getHeight(); final Point location = new Point(x, y); SwingUtilities.convertPointToScreen(location, c); UITools.setBounds(dialog, location.x, location.y, dialog.getWidth(), dialog.getHeight()); }
/** * Save settings for a dialog * * @param dialog * the dialog */ public void saveSettings(JDialog dialog) { if (!dialog.getName().contains("dialog")) { storeWindowBounds(dialog.getName(), dialog.getX(), dialog.getY(), dialog.getWidth(), dialog.getHeight()); } }
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); }
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); }
public void storeDialogPositions(final JDialog dialog, final String window_preference_storage_property) { setX((dialog.getX())); setY((dialog.getY())); setWidth((dialog.getWidth())); setHeight((dialog.getHeight())); final String marshalled = marshall(); ResourceController.getResourceController().setProperty(window_preference_storage_property, marshalled); }