List of usage examples for javax.swing JDialog getLocation
public Point getLocation()
From source file:Main.java
public static void setCenterOfParent(JDialog parent, JDialog dialog) { Point parentPosition = parent.getLocation(); Dimension parentSize = parent.getSize(); Dimension size = dialog.getSize(); Point position = new Point(parentPosition.x + (parentSize.width / 2 - size.width / 2), parentPosition.y + (parentSize.height / 2 - size.height / 2)); dialog.setLocation(position);//from w w w.ja v a 2 s .c o m }
From source file:net.lmxm.ute.gui.validation.AbstractInputValidator.java
/** * Display messages dialog.// www. ja va 2 s . c om * * @param component the component * @param messages the messages */ private void displayMessagesDialog(final JComponent component, final List<String> messages) { final JDialog dialog = getMessagesDialog(); // Load dialog with messages. getMessagesLabel().setText(StringUtils.join(messages, "\n")); // Relocate dialog relative to the input component dialog.setSize(0, 0); dialog.setLocationRelativeTo(component); final Point location = dialog.getLocation(); final Dimension componentSize = component.getSize(); dialog.setLocation(location.x - (int) componentSize.getWidth() / 2, location.y + (int) componentSize.getHeight() / 2); dialog.pack(); dialog.setVisible(true); }