private void initialize() { this.setVisible(false); this.getStyleClass().add(DEFAULT_STYLE_CLASS); this.transitionType.addListener((o, oldVal, newVal) -> { animation = getShowAnimation(transitionType.get()); }); contentHolder = new StackPane(); contentHolder.setBackground(new Background(new BackgroundFill(Color.WHITE, new CornerRadii(2), null))); JFXDepthManager.setDepth(contentHolder, 4); contentHolder.setPickOnBounds(false); // ensure stackpane is never resized beyond it's preferred size contentHolder.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE); this.getChildren().add(contentHolder); this.getStyleClass().add("jfx-dialog-overlay-pane"); StackPane.setAlignment(contentHolder, Pos.CENTER); this.setBackground(new Background(new BackgroundFill(Color.rgb(0, 0, 0, 0.1), null, null))); // close the dialog if clicked on the overlay pane if (overlayClose.get()) { this.addEventHandler(MouseEvent.MOUSE_PRESSED, closeHandler); } // prevent propagating the events to overlay pane contentHolder.addEventHandler(MouseEvent.ANY, e -> e.consume()); }
/** * close the dialog */ public void close() { if (animation != null) { animation.setRate(-1); animation.play(); animation.setOnFinished(e -> { closeDialog(); }); } else { setOpacity(0); setVisible(false); closeDialog(); } }
@Override public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() { if (STYLEABLES == null) { final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>(Parent.getClassCssMetaData()); styleables.addAll(getClassCssMetaData()); styleables.addAll(StackPane.getClassCssMetaData()); STYLEABLES = Collections.unmodifiableList(styleables); } return STYLEABLES; }
private void initChangeListeners() { overlayCloseProperty().addListener((o, oldVal, newVal) -> { if (newVal) { this.addEventHandler(MouseEvent.MOUSE_PRESSED, closeHandler); } else { this.removeEventHandler(MouseEvent.MOUSE_PRESSED, closeHandler); } }); }
/** * creates JFXDialog control with a specified animation type, the animation type * can be one of the following: * <ul> * <li>CENTER</li> * <li>TOP</li> * <li>RIGHT</li> * <li>BOTTOM</li> * <li>LEFT</li> * </ul> * * @param dialogContainer is the parent of the dialog, it * @param content the content of dialog * @param transitionType the animation type */ public JFXDialog(StackPane dialogContainer, Region content, DialogTransition transitionType) { initialize(); setContent(content); setDialogContainer(dialogContainer); this.transitionType.set(transitionType); // init change listeners initChangeListeners(); }
@Override public void show() { if (!jfxDatePicker.isOverLay()) { super.show(); } if (content != null) { content.init(); content.clearFocus(); } if (dialog == null && jfxDatePicker.isOverLay()) { StackPane dialogParent = jfxDatePicker.getDialogParent(); if (dialogParent == null) { dialogParent = (StackPane) jfxDatePicker.getScene().getRoot(); } dialog = new JFXDialog(dialogParent, (Region) getPopupContent(), DialogTransition.CENTER, true); arrowButton.setOnMouseClicked((click) -> { if (jfxDatePicker.isOverLay()) { StackPane parent = jfxDatePicker.getDialogParent(); if (parent == null) { parent = (StackPane) jfxDatePicker.getScene().getRoot(); } dialog.show(parent); } }); } }
content.setActions(buttonYes, buttonNo); content.getStyleClass().add("confirmDialogContentBackground"); final JFXDialog dialog = new JFXDialog(mainPane, content, JFXDialog.DialogTransition.CENTER); dialog.getStyleClass().add("confirmDialogBackground"); buttonYes.setOnMouseClicked(ev); buttonNo.setOnMouseClicked(ev); buttonYes.setOnAction(t -> dialog.close()); buttonNo.setOnAction(t -> dialog.close()); dialog.show();
content.setBody(descrizione); content.getStyleClass().add("dialogContentBackground"); final JFXDialog dialog = new JFXDialog(mainPane, content, JFXDialog.DialogTransition.CENTER); dialog.getStyleClass().add("dialogBackground"); dialog.show(); content.setCache(true); content.setCacheHint(CacheHint.SPEED); dialog.setOnMouseClicked(ev);
dialog.setTransitionType(DialogTransition.CENTER); dialog.show((StackPane) context.getRegisteredObject(CONTENT_PANE)); }); dialog.setTransitionType(DialogTransition.TOP); dialog.show((StackPane) context.getRegisteredObject(CONTENT_PANE)); }); dialog.setTransitionType(DialogTransition.RIGHT); dialog.show((StackPane) context.getRegisteredObject(CONTENT_PANE)); }); dialog.setTransitionType(DialogTransition.BOTTOM); dialog.show((StackPane) context.getRegisteredObject(CONTENT_PANE)); }); dialog.setTransitionType(DialogTransition.LEFT); dialog.show((StackPane) context.getRegisteredObject(CONTENT_PANE)); }); acceptButton.setOnAction(action -> dialog.close());
/** * set the dialog container * Note: the dialog container must be StackPane, its the container for the dialog to be shown in. * * @param dialogContainer */ public void setDialogContainer(StackPane dialogContainer) { if (dialogContainer != null) { this.dialogContainer = dialogContainer; // FIXME: need to be improved to consider only the parent boundary offsetX = dialogContainer.getBoundsInLocal().getWidth(); offsetY = dialogContainer.getBoundsInLocal().getHeight(); animation = getShowAnimation(transitionType.get()); } }
/** * creates JFXDialog control with a specified animation type that * is closed when clicking on the overlay, the animation type * can be one of the following: * <ul> * <li>CENTER</li> * <li>TOP</li> * <li>RIGHT</li> * <li>BOTTOM</li> * <li>LEFT</li> * </ul> * * @param dialogContainer * @param content * @param transitionType * @param overlayClose */ public JFXDialog(StackPane dialogContainer, Region content, DialogTransition transitionType, boolean overlayClose) { setOverlayClose(overlayClose); initialize(); setContent(content); setDialogContainer(dialogContainer); this.transitionType.set(transitionType); // init change listeners initChangeListeners(); }
@Override public void show() { if (!jfxTimePicker.isOverLay()) { super.show(); } if (content != null) { content.init(); content.clearFocus(); } if (dialog == null && jfxTimePicker.isOverLay()) { StackPane dialogParent = jfxTimePicker.getDialogParent(); if (dialogParent == null) { dialogParent = (StackPane) jfxTimePicker.getScene().getRoot(); } dialog = new JFXDialog(dialogParent, (Region) getPopupContent(), DialogTransition.CENTER, true); arrowButton.setOnMouseClicked((click) -> { if (jfxTimePicker.isOverLay()) { StackPane parent = jfxTimePicker.getDialogParent(); if (parent == null) { parent = (StackPane) jfxTimePicker.getScene().getRoot(); } dialog.show(parent); } }); } }
private void initChangeListeners() { overlayCloseProperty().addListener((o, oldVal, newVal) -> { if (newVal) { this.addEventHandler(MouseEvent.MOUSE_PRESSED, closeHandler); } else { this.removeEventHandler(MouseEvent.MOUSE_PRESSED, closeHandler); } }); }
/** * set the dialog container * Note: the dialog container must be StackPane, its the container for the dialog to be shown in. * * @param dialogContainer */ public void setDialogContainer(StackPane dialogContainer) { if (dialogContainer != null) { this.dialogContainer = dialogContainer; // FIXME: need to be improved to consider only the parent boundary offsetX = dialogContainer.getBoundsInLocal().getWidth(); offsetY = dialogContainer.getBoundsInLocal().getHeight(); animation = getShowAnimation(transitionType.get()); } }
/** * creates JFXDialog control with a specified animation type, the animation type * can be one of the following: * <ul> * <li>CENTER</li> * <li>TOP</li> * <li>RIGHT</li> * <li>BOTTOM</li> * <li>LEFT</li> * </ul> * * @param dialogContainer is the parent of the dialog, it * @param content the content of dialog * @param transitionType the animation type */ public JFXDialog(StackPane dialogContainer, Region content, DialogTransition transitionType) { initialize(); setContent(content); setDialogContainer(dialogContainer); this.transitionType.set(transitionType); // init change listeners initChangeListeners(); }
private void initialize() { this.setVisible(false); this.getStyleClass().add(DEFAULT_STYLE_CLASS); this.transitionType.addListener((o, oldVal, newVal) -> { animation = getShowAnimation(transitionType.get()); }); contentHolder = new StackPane(); contentHolder.setBackground(new Background(new BackgroundFill(Color.WHITE, new CornerRadii(2), null))); JFXDepthManager.setDepth(contentHolder, 4); contentHolder.setPickOnBounds(false); // ensure stackpane is never resized beyond it's preferred size contentHolder.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE); this.getChildren().add(contentHolder); this.getStyleClass().add("jfx-dialog-overlay-pane"); StackPane.setAlignment(contentHolder, Pos.CENTER); this.setBackground(new Background(new BackgroundFill(Color.rgb(0, 0, 0, 0.1), null, null))); // close the dialog if clicked on the overlay pane if (overlayClose.get()) { this.addEventHandler(MouseEvent.MOUSE_PRESSED, closeHandler); } // prevent propagating the events to overlay pane contentHolder.addEventHandler(MouseEvent.ANY, e -> e.consume()); }
@Override public void show() { if (!jfxTimePicker.isOverLay()) { super.show(); } if (content != null) { content.init(); content.clearFocus(); } if (dialog == null && jfxTimePicker.isOverLay()) { StackPane dialogParent = jfxTimePicker.getDialogParent(); if (dialogParent == null) { dialogParent = (StackPane) jfxTimePicker.getScene().getRoot(); } dialog = new JFXDialog(dialogParent, (Region) getPopupContent(), DialogTransition.CENTER, true); arrowButton.setOnMouseClicked((click) -> { if (jfxTimePicker.isOverLay()) { StackPane parent = jfxTimePicker.getDialogParent(); if (parent == null) { parent = (StackPane) jfxTimePicker.getScene().getRoot(); } dialog.show(parent); } }); } }
/** * close the dialog */ public void close() { if (animation != null) { animation.setRate(-1); animation.play(); animation.setOnFinished(e -> { closeDialog(); }); } else { setOpacity(0); setVisible(false); closeDialog(); } }
@Override public List<CssMetaData<? extends Styleable, ?>> getCssMetaData() { if (STYLEABLES == null) { final List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>(Parent.getClassCssMetaData()); styleables.addAll(getClassCssMetaData()); styleables.addAll(StackPane.getClassCssMetaData()); STYLEABLES = Collections.unmodifiableList(styleables); } return STYLEABLES; }
/** * creates JFXDialog control with a specified animation type that * is closed when clicking on the overlay, the animation type * can be one of the following: * <ul> * <li>CENTER</li> * <li>TOP</li> * <li>RIGHT</li> * <li>BOTTOM</li> * <li>LEFT</li> * </ul> * * @param dialogContainer * @param content * @param transitionType * @param overlayClose */ public JFXDialog(StackPane dialogContainer, Region content, DialogTransition transitionType, boolean overlayClose) { setOverlayClose(overlayClose); initialize(); setContent(content); setDialogContainer(dialogContainer); this.transitionType.set(transitionType); // init change listeners initChangeListeners(); }