/** * Sets the position of the window on the screen using * {@link #setPositionX(int)} and {@link #setPositionY(int)}. * * @since 7.5 * @param x * The new x coordinate for the window * @param y * The new y coordinate for the window */ public void setPosition(int x, int y) { setPositionX(x); setPositionY(y); }
@Override public void windowMoved(int x, int y) { if (x != getState(false).positionX) { setPositionX(x); } if (y != getState(false).positionY) { setPositionY(y); } } };
setPositionY(y < 0 ? -1 : y);
@Override public void readDesign(Element design, DesignContext context) { super.readDesign(design, context); if (design.hasAttr("center")) { center(); } if (design.hasAttr("position")) { String[] position = design.attr("position").split(","); setPositionX(Integer.parseInt(position[0])); setPositionY(Integer.parseInt(position[1])); } // Parse shortcuts if defined, otherwise rely on default behavior if (design.hasAttr("close-shortcut")) { // Parse shortcuts String[] shortcutStrings = DesignAttributeHandler .readAttribute("close-shortcut", design.attributes(), String.class) .split("\\s+"); removeAllCloseShortcuts(); for (String part : shortcutStrings) { if (!part.isEmpty()) { ShortcutAction shortcut = DesignAttributeHandler .getFormatter() .parse(part.trim(), ShortcutAction.class); addCloseShortcut(shortcut.getKeyCode(), shortcut.getModifiers()); } } } }
/** * Forces a y position for the message dialog. * * @param y The y position * @return The {@link MessageBox} instance itself */ public MessageBox withDialogPositionY(int y) { window.setPositionY(y); return this; }
private void toggleWindow(final ClickEvent event) { if (notificationsWindow.isAttached()) { getUI().removeWindow(notificationsWindow); return; } createUnreadMessagesLayout(); notificationsWindow.setPositionY(event.getClientY() - event.getRelativeY() + 40); getUI().addWindow(notificationsWindow); currentView.refreshView(unreadNotifications.keySet()); clear(); notificationsWindow.focus(); }
private void toggleWindow(final ClickEvent event) { if (notificationsWindow.isAttached()) { getUI().removeWindow(notificationsWindow); return; } createUnreadMessagesLayout(); notificationsWindow.setPositionY(event.getClientY() - event.getRelativeY() + 40); getUI().addWindow(notificationsWindow); currentView.refreshView(unreadNotifications.keySet()); clear(); notificationsWindow.focus(); }
notificationsWindow.setPositionY(event.getClientY() - event.getRelativeY() + 40); notificationsWindow.setPositionX(event.getClientX() - event.getRelativeX() - 300); getUI().addWindow(notificationsWindow);