public void show(Window window, double x, double y, PopupVPosition vAlign, PopupHPosition hAlign, double initOffsetX, double initOffsetY) { if (!isShowing()) { if (window == null) { throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); } Window parent = window; final double anchorX = parent.getX() + x + initOffsetX; final double anchorY = parent.getY() + y + initOffsetY; this.show(parent, anchorX, anchorY); ((JFXPopupSkin) getSkin()).reset(vAlign, hAlign, initOffsetX, initOffsetY); Platform.runLater(() -> ((JFXPopupSkin) getSkin()).animate()); } }
/** * init fxml when loaded. */ @PostConstruct public void init() { try { popup = new JFXPopup(FXMLLoader.load(getClass().getResource("/fxml/ui/popup/DemoPopup.fxml"))); } catch (IOException ioExc) { ioExc.printStackTrace(); } burger1.setOnMouseClicked((e) -> popup.show(rippler1, PopupVPosition.TOP, PopupHPosition.LEFT)); burger2.setOnMouseClicked((e) -> popup.show(rippler2, PopupVPosition.TOP, PopupHPosition.RIGHT)); burger3.setOnMouseClicked((e) -> popup.show(rippler3, PopupVPosition.BOTTOM, PopupHPosition.LEFT)); burger4.setOnMouseClicked((e) -> popup.show(rippler4, PopupVPosition.BOTTOM, PopupHPosition.RIGHT)); } }
private void initialize() { this.setAutoFix(false); this.setAutoHide(true); this.setHideOnEscape(true); this.setConsumeAutoHidingEvents(false); this.getStyleClass().add(DEFAULT_STYLE_CLASS); }
/** * creates popup with a specified container and content * * @param content the node that will be shown in the popup */ public JFXPopup(Region content) { setPopupContent(content); initialize(); }
/** * show the popup using the default position */ public void show(Node node) { this.show(node, PopupVPosition.TOP, PopupHPosition.LEFT, 0, 0); }
public final Region getPopupContent() { return this.popupContentProperty().get(); }
@Override public void hide() { super.hide(); ((JFXPopupSkin) getSkin()).init(); }
public JFXPopupSkin(JFXPopup control) { this.control = control; // set scale y to 0.01 instead of 0 to allow layout of the content, // otherwise it will cause exception in traverse engine, when focusing the 1st node scale = new Scale(1, 0.01, 0, 0); popupContent = control.getPopupContent(); container.getStyleClass().add("jfx-popup-container"); container.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY))); container.getChildren().add(popupContent); container.getTransforms().add(scale); container.setOpacity(0); root = JFXDepthManager.createMaterialNode(container, 4); animation = getAnimation(); }
/** * show the popup according to the specified position * * @param vAlign can be TOP/BOTTOM * @param hAlign can be LEFT/RIGHT */ public void show(Node node, PopupVPosition vAlign, PopupHPosition hAlign) { this.show(node, vAlign, hAlign, 0, 0); }
/** * creates popup with a specified container and content * * @param content the node that will be shown in the popup */ public JFXPopup(Region content) { setPopupContent(content); initialize(); }
public final void setPopupContent(final Region popupContent) { this.popupContentProperty().set(popupContent); }
@Override public void hide() { super.hide(); ((JFXPopupSkin) getSkin()).init(); }
public JFXPopupSkin(JFXPopup control) { this.control = control; // set scale y to 0.01 instead of 0 to allow layout of the content, // otherwise it will cause exception in traverse engine, when focusing the 1st node scale = new Scale(1, 0.01, 0, 0); popupContent = control.getPopupContent(); container.getStyleClass().add("jfx-popup-container"); container.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY))); container.getChildren().add(popupContent); container.getTransforms().add(scale); container.setOpacity(0); root = JFXDepthManager.createMaterialNode(container, 4); animation = getAnimation(); }
/** * show the popup according to the specified position with a certain offset * * @param vAlign can be TOP/BOTTOM * @param hAlign can be LEFT/RIGHT * @param initOffsetX on the x axis * @param initOffsetY on the y axis */ public void show(Node node, PopupVPosition vAlign, PopupHPosition hAlign, double initOffsetX, double initOffsetY) { if (!isShowing()) { if (node.getScene() == null || node.getScene().getWindow() == null) { throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); } Window parent = node.getScene().getWindow(); final Point2D origin = node.localToScene(0, 0); final double anchorX = parent.getX() + origin.getX() + node.getScene().getX() + (hAlign == PopupHPosition.RIGHT ? ((Region) node).getWidth() : 0); final double anchorY = parent.getY() + origin.getY() + node.getScene() .getY() + (vAlign == PopupVPosition.BOTTOM ? ((Region) node).getHeight() : 0); this.show(parent, anchorX, anchorY); ((JFXPopupSkin) getSkin()).reset(vAlign, hAlign, initOffsetX, initOffsetY); Platform.runLater(() -> ((JFXPopupSkin) getSkin()).animate()); } }
private void initialize() { this.setAutoFix(false); this.setAutoHide(true); this.setHideOnEscape(true); this.setConsumeAutoHidingEvents(false); this.getStyleClass().add(DEFAULT_STYLE_CLASS); }
@Override public void start(Stage primaryStage) throws Exception { JFXHamburger show = new JFXHamburger(); show.setPadding(new Insets(10, 5, 10, 5)); JFXRippler rippler = new JFXRippler(show, RipplerMask.CIRCLE, RipplerPos.BACK); JFXListView<Label> list = new JFXListView<>(); for (int i = 1; i < 5; i++) { list.getItems().add(new Label("Item " + i)); } AnchorPane container = new AnchorPane(); container.getChildren().add(rippler); AnchorPane.setLeftAnchor(rippler, 200.0); AnchorPane.setTopAnchor(rippler, 210.0); StackPane main = new StackPane(); main.getChildren().add(container); JFXPopup popup = new JFXPopup(list); rippler.setOnMouseClicked(e -> popup.show(rippler, PopupVPosition.TOP, PopupHPosition.LEFT)); final Scene scene = new Scene(main, 800, 800); scene.getStylesheets().add(PopupDemo.class.getResource("/css/jfoenix-components.css").toExternalForm()); primaryStage.setTitle("JFX Popup Demo"); primaryStage.setScene(scene); primaryStage.setResizable(false); primaryStage.show(); }
/** * show the popup according to the specified position * * @param vAlign can be TOP/BOTTOM * @param hAlign can be LEFT/RIGHT */ public void show(Node node, PopupVPosition vAlign, PopupHPosition hAlign) { this.show(node, vAlign, hAlign, 0, 0); }
public final Region getPopupContent() { return this.popupContentProperty().get(); }
public void show(Window window, double x, double y, PopupVPosition vAlign, PopupHPosition hAlign, double initOffsetX, double initOffsetY) { if (!isShowing()) { if (window == null) { throw new IllegalStateException("Can not show popup. The node must be attached to a scene/window."); } Window parent = window; final double anchorX = parent.getX() + x + initOffsetX; final double anchorY = parent.getY() + y + initOffsetY; this.show(parent, anchorX, anchorY); ((JFXPopupSkin) getSkin()).reset(vAlign, hAlign, initOffsetX, initOffsetY); Platform.runLater(() -> ((JFXPopupSkin) getSkin()).animate()); } }