Java Code Examples for javafx.stage.Popup#setAnchorLocation()
The following examples show how to use
javafx.stage.Popup#setAnchorLocation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PopupSelectbox.java From logbook-kai with MIT License | 6 votes |
public void show(Node anchorNode) { PopupSelectboxContainer<T> container = new PopupSelectboxContainer<>(); container.setItems(this.items.get()); container.setCellFactory(this.cellFactory.get()); container.setSelectedItem(this.selectedItem); container.getStylesheets().addAll(this.styleSheets); container.headerContents().addAll(this.headerContents); container.init(); Popup stage = new Popup(); stage.getContent().addAll(container); stage.setAutoHide(true); stage.setAnchorLocation(PopupWindow.AnchorLocation.CONTENT_TOP_LEFT); Bounds screen = anchorNode.localToScreen(anchorNode.getLayoutBounds()); stage.show(anchorNode.getScene().getWindow(), screen.getMinX(), screen.getMaxY()); }
Example 2
Source File: PopOver.java From logbook-kai with MIT License | 5 votes |
/** * マウスがこのアンカーノードに入るときに呼び出される関数を定義します。 * * @param event {@link MouseEvent} */ protected void setOnMouseEntered(MouseEvent event) { Node anchorNode = (Node) event.getSource(); Popup popup = this.initPopup(anchorNode); Bounds screen = anchorNode.localToScreen(anchorNode.getLayoutBounds()); popup.setAnchorLocation(PopupWindow.AnchorLocation.CONTENT_TOP_LEFT); popup.show(anchorNode.getScene().getWindow(), screen.getMinX(), screen.getMaxY()); this.setLocation(popup, anchorNode, event); }
Example 3
Source File: PopOver.java From logbook-kai with MIT License | 4 votes |
/** * ポップアップの表示位置を設定します * * @param popup ポップアップ * @param anchorNode アンカーノード * @param event {@link MouseEvent} */ protected void setLocation(Popup popup, Node anchorNode, MouseEvent event) { double x = event.getScreenX(); double y = event.getScreenY(); double width = popup.getWidth(); double height = popup.getHeight(); double gapSize = this.getGapSize(); PopupWindow.AnchorLocation anchorLocation = PopupWindow.AnchorLocation.CONTENT_TOP_LEFT; double gapX = gapSize; double gapY = gapSize; for (Screen screen : Screen.getScreens()) { Rectangle2D screenRect = screen.getVisualBounds(); // 右下 に表示可能であれば if (screenRect.contains(x + gapSize, y + gapSize, width, height)) { // PopupWindow視点でアンカーノードがTOP_LEFTの位置 anchorLocation = PopupWindow.AnchorLocation.CONTENT_TOP_LEFT; gapX = gapSize; gapY = gapSize; break; } // 左下 if (screenRect.contains(x - gapSize - width, y + gapSize, width, height)) { anchorLocation = PopupWindow.AnchorLocation.CONTENT_TOP_RIGHT; gapX = -gapSize; gapY = gapSize; break; } // 右上 if (screenRect.contains(x + gapSize, y - gapSize - height, width, height)) { anchorLocation = PopupWindow.AnchorLocation.CONTENT_BOTTOM_LEFT; gapX = gapSize; gapY = -gapSize; break; } // 左上 if (screenRect.contains(x - gapSize - width, y - gapSize - height, width, height)) { anchorLocation = PopupWindow.AnchorLocation.CONTENT_BOTTOM_RIGHT; gapX = -gapSize; gapY = -gapSize; break; } } popup.setAnchorLocation(anchorLocation); popup.setAnchorX(x + gapX); popup.setAnchorY(y + gapY); }