List of usage examples for java.awt Container getLocationOnScreen
public Point getLocationOnScreen()
From source file:org.isatools.isacreatorconfigurator.configui.FieldInterface.java
private void showPopupInCenter(Window container) { Container parent = main; Point parentLocation = parent.getLocationOnScreen(); Dimension parentSize = parent.getSize(); int calcedXLoc = (parentLocation.x) + ((parentSize.width) / 2) - (container.getWidth() / 2); int calcedYLoc = (parentLocation.y) + ((parentSize.height) / 2) - (container.getHeight() / 2); container.setVisible(true);/* w w w. j a v a2s. c o m*/ container.setLocation(calcedXLoc, calcedYLoc); container.toFront(); container.requestFocusInWindow(); }
From source file:phex.gui.common.FileDialogHandler.java
/** * @param chooser//from www .j a v a2 s . co m */ private static void displayNotificationPopup(JComponent chooser, String title, String shortMessage) { final SlideInWindow window = new SlideInWindow(title, 0); window.setShortMessage(shortMessage, true); window.setHideBtnShown(false); window.initializeComponent(); window.setSize(200, 150); chooser.addAncestorListener(new AncestorListener() { public void ancestorAdded(AncestorEvent event) { window.setVisible(true); } public void ancestorRemoved(AncestorEvent event) { window.setVisible(false); } public void ancestorMoved(AncestorEvent event) { Container ancestor = event.getAncestor(); Point loc = ancestor.getLocationOnScreen(); int xPos = loc.x + ancestor.getWidth() + 5; int yPos = loc.y + ancestor.getHeight() - window.getHeight(); window.setLocation(xPos, yPos); } }); }