javafx.stage.Popup Java Examples

The following examples show how to use javafx.stage.Popup. 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: CardRevealedToken.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public CardRevealedToken(GameBoardView boardView, Card card, double delay) {
	Window parent = boardView.getScene().getWindow();
	this.cardToken = new CardTooltip();

	popup = new Popup();
	popup.getContent().setAll(cardToken);
	popup.setX(parent.getX() + 40);
	popup.show(parent);
	popup.setY(parent.getY() + parent.getHeight() * 0.5 - cardToken.getHeight() * 0.5);

	cardToken.setCard(card);
	NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
	FadeTransition animation = new FadeTransition(Duration.seconds(delay), cardToken);
	animation.setOnFinished(this::secondTransition);
	animation.setFromValue(0);
	animation.setToValue(0);
	animation.play();
}
 
Example #2
Source File: Notifications.java    From yfiton with Apache License 2.0 6 votes vote down vote up
private Timeline createHideTimeline(final Popup popup, NotificationBar bar, final Pos p, Duration startDelay, Notifications notification) {
    KeyValue fadeOutBegin = new KeyValue(bar.opacityProperty(), 1.0);
    KeyValue fadeOutEnd = new KeyValue(bar.opacityProperty(), 0.0);

    KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
    KeyFrame kfEnd = new KeyFrame(Duration.millis(500), fadeOutEnd);

    Timeline timeline = new Timeline(kfBegin, kfEnd);
    timeline.setDelay(startDelay);
    timeline.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            hide(popup, p);
            notification.onHideAction.handle(e);
        }
    });

    return timeline;
}
 
Example #3
Source File: ListViewHelperMainController.java    From examples-javafx-repos1 with Apache License 2.0 6 votes vote down vote up
@FXML
public void showEmployeesHelper(ActionEvent evt) {
	
	Button btn = (Button)evt.getSource();
	
	Point2D point = btn.localToScreen(0.0d + btn.getWidth(), 0.0d - btn.getHeight());
	
	try {
		
		Popup employeesHelper = new ListViewHelperEmployeesPopup(tfEmployee, point);
		
		employeesHelper.show(btn.getScene().getWindow());
	
	} catch(Exception exc) {
		exc.printStackTrace();
		Alert alert = new Alert(AlertType.ERROR, "Error creating employees popup; exiting");
		alert.showAndWait();
		btn.getScene().getWindow().hide();  // close and implicit exit
	}
}
 
Example #4
Source File: CardPlayedToken.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public CardPlayedToken(GameBoardView boardView, Card card) {
	Window parent = boardView.getScene().getWindow();
	this.cardToken = new CardTooltip();

	popup = new Popup();
	popup.getContent().setAll(cardToken);
	popup.setX(parent.getX() + 40);
	popup.show(parent);
	popup.setY(parent.getY() + parent.getHeight() * 0.5 - cardToken.getHeight() * 0.5);

	cardToken.setCard(card);

	NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
	FadeTransition animation = new FadeTransition(Duration.seconds(1.2), cardToken);
	animation.setDelay(Duration.seconds(0.6f));
	animation.setOnFinished(this::onComplete);
	animation.setFromValue(1);
	animation.setToValue(0);
	animation.play();
}
 
Example #5
Source File: Notifications.java    From yfiton with Apache License 2.0 6 votes vote down vote up
private Timeline createHideTimeline(final Popup popup, NotificationBar bar, final Pos p, Duration startDelay, Notifications notification) {
    KeyValue fadeOutBegin = new KeyValue(bar.opacityProperty(), 1.0);
    KeyValue fadeOutEnd = new KeyValue(bar.opacityProperty(), 0.0);

    KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
    KeyFrame kfEnd = new KeyFrame(Duration.millis(500), fadeOutEnd);

    Timeline timeline = new Timeline(kfBegin, kfEnd);
    timeline.setDelay(startDelay);
    timeline.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            hide(popup, p);
            notification.onHideAction.handle(e);
        }
    });

    return timeline;
}
 
Example #6
Source File: FxmlControl.java    From MyBox with Apache License 2.0 6 votes vote down vote up
public static void popText(String text, String color, String size,
        Stage stage) {
    try {
        Popup popup = new Popup();
        popup.setAutoHide(true);
        popup.setAutoFix(true);
        Label popupLabel = new Label(text);
        popupLabel.setStyle("-fx-background-color:black;"
                + " -fx-text-fill: " + color + ";"
                + " -fx-font-size: " + size + ";"
                + " -fx-padding: 10px;"
                + " -fx-background-radius: 6;");
        popup.getContent().add(popupLabel);

        popup.show(stage);

    } catch (Exception e) {

    }
}
 
Example #7
Source File: PopupSelectbox.java    From logbook-kai with MIT License 6 votes vote down vote up
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 #8
Source File: Notifications.java    From oim-fx with MIT License 6 votes vote down vote up
private Timeline createHideTimeline(final Popup popup, NotificationBar bar, final Pos p, Duration startDelay) {
    KeyValue fadeOutBegin = new KeyValue(bar.opacityProperty(), 1.0);
    KeyValue fadeOutEnd = new KeyValue(bar.opacityProperty(), 0.0);

    KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
    KeyFrame kfEnd = new KeyFrame(Duration.millis(500), fadeOutEnd);

    Timeline timeline = new Timeline(kfBegin, kfEnd);
    timeline.setDelay(startDelay);
    timeline.setOnFinished(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent e) {
            hide(popup, p);
        }
    });

    return timeline;
}
 
Example #9
Source File: JoustToken.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
public JoustToken(GameBoardView boardView, Card card, boolean up, boolean won) {
	Window parent = boardView.getScene().getWindow();
	this.cardToken = new CardTooltip();

	popup = new Popup();
	popup.getContent().setAll(cardToken);
	popup.setX(parent.getX() + 600);
	popup.show(parent);
	int offsetY = up ? -200 : 100;
	popup.setY(parent.getY() + parent.getHeight() * 0.5 - cardToken.getHeight() * 0.5 + offsetY);

	cardToken.setCard(card);

	NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
	FadeTransition animation = new FadeTransition(Duration.seconds(1.0), cardToken);
	animation.setDelay(Duration.seconds(1f));
	animation.setOnFinished(this::onComplete);
	animation.setFromValue(1);
	animation.setToValue(0);
	animation.play();
	
	if (won) {
		ScaleTransition scaleAnimation = new ScaleTransition(Duration.seconds(0.5f), cardToken);
		scaleAnimation.setByX(0.1);
		scaleAnimation.setByY(0.1);
		scaleAnimation.setCycleCount(2);
		scaleAnimation.setAutoReverse(true);
		scaleAnimation.play();	
	}
}
 
Example #10
Source File: TooltipDemo.java    From RichTextFX with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void start(Stage stage) {
    StyleClassedTextArea area = new StyleClassedTextArea();
    area.setWrapText(true);
    area.appendText("Pause the mouse over the text for 1 second.");

    Popup popup = new Popup();
    Label popupMsg = new Label();
    popupMsg.setStyle(
            "-fx-background-color: black;" +
            "-fx-text-fill: white;" +
            "-fx-padding: 5;");
    popup.getContent().add(popupMsg);

    area.setMouseOverTextDelay(Duration.ofSeconds(1));
    area.addEventHandler(MouseOverTextEvent.MOUSE_OVER_TEXT_BEGIN, e -> {
        int chIdx = e.getCharacterIndex();
        Point2D pos = e.getScreenPosition();
        popupMsg.setText("Character '" + area.getText(chIdx, chIdx+1) + "' at " + pos);
        popup.show(area, pos.getX(), pos.getY() + 10);
    });
    area.addEventHandler(MouseOverTextEvent.MOUSE_OVER_TEXT_END, e -> {
        popup.hide();
    });

    Scene scene = new Scene(area, 600, 400);
    stage.setScene(scene);
    stage.setTitle("Tooltip Demo");
    stage.show();
}
 
Example #11
Source File: LongTextField.java    From milkman with MIT License 5 votes vote down vote up
public LongTextField() {
    popup = new Popup();
    popup.setAutoHide(true);
    popup.setHideOnEscape(true);
    popup.setConsumeAutoHidingEvents(false);

    content = new JFXTextArea();
    content.setBackground(new Background(new BackgroundFill(Color.rgb(255,255,255), null, null)));
    content.setPrefHeight(60);
    content.setWrapText(false);
    popup.getContent().add(new VBox(content));


    setupListener();
}
 
Example #12
Source File: Notifications.java    From yfiton with Apache License 2.0 5 votes vote down vote up
private void addPopupToMap(Pos p, Popup popup) {
    List<Popup> popups;
    if (!popupsMap.containsKey(p)) {
        popups = new LinkedList<>();
        popupsMap.put(p, popups);
    } else {
        popups = popupsMap.get(p);
    }

    doAnimation(p, popup);

    // add the popup to the list so it is kept in memory and can be
    // accessed later on
    popups.add(popup);
}
 
Example #13
Source File: SimplePopups.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Show a transient popup with a message, to let the user know an action
 * was performed.
 *
 * @param owner Node next to which the popup will be shown
 * @return
 */
public static EventStream<?> showActionFeedback(@NonNull Node owner,
                                                @Nullable Node graphic,
                                                @NonNull String message,
                                                double offsetX,
                                                boolean stick,
                                                String... cssClasses) {

    Popup popup = new Popup();
    Label label = new Label(message, graphic);
    StackPane pane = new StackPane();

    DesignerUtil.addCustomStyleSheets(pane, "designer");
    pane.getStyleClass().addAll("action-feedback");
    pane.getStyleClass().addAll(cssClasses);

    pane.getChildren().addAll(label);
    popup.getContent().addAll(pane);

    Animation fadeTransition = stick ? fadeInAnimation(pane) : bounceFadeAnimation(pane);
    EventSource<?> closeTick = new EventSource<>();
    if (stick) {
        pane.setOnMouseClicked(evt -> {
            popup.hide();
            closeTick.push(null);
        });
    } else {
        fadeTransition.setOnFinished(e -> {
            popup.hide();
            closeTick.push(null);
        });
    }

    popup.setOnShowing(e -> fadeTransition.play());

    Bounds screenBounds = owner.localToScreen(owner.getBoundsInLocal());
    popup.show(owner, screenBounds.getMaxX() + offsetX, screenBounds.getMinY());
    return closeTick;
}
 
Example #14
Source File: Notifications.java    From yfiton with Apache License 2.0 5 votes vote down vote up
private void addPopupToMap(Pos p, Popup popup) {
    List<Popup> popups;
    if (!popupsMap.containsKey(p)) {
        popups = new LinkedList<>();
        popupsMap.put(p, popups);
    } else {
        popups = popupsMap.get(p);
    }

    doAnimation(p, popup);

    // add the popup to the list so it is kept in memory and can be
    // accessed later on
    popups.add(popup);
}
 
Example #15
Source File: PopOver.java    From logbook-kai with MIT License 5 votes vote down vote up
/**
 * マウスがこのアンカーノードに入るときに呼び出される関数を定義します。
 *
 * @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 #16
Source File: Notifications.java    From oim-fx with MIT License 5 votes vote down vote up
private void addPopupToMap(Pos p, Popup popup) {
    List<Popup> popups;
    if (!popupsMap.containsKey(p)) {
        popups = new LinkedList<>();
        popupsMap.put(p, popups);
    } else {
        popups = popupsMap.get(p);
    }

    doAnimation(p, popup);

    // add the popup to the list so it is kept in memory and can be
    // accessed later on
    popups.add(popup);
}
 
Example #17
Source File: MyBoxController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
private void makeImagePopup() {
    try {
        imagePop = new Popup();
        imagePop.setWidth(600);
        imagePop.setHeight(600);

        VBox vbox = new VBox();
        VBox.setVgrow(vbox, Priority.ALWAYS);
        HBox.setHgrow(vbox, Priority.ALWAYS);
        vbox.setMaxWidth(Double.MAX_VALUE);
        vbox.setMaxHeight(Double.MAX_VALUE);
        vbox.setStyle("-fx-background-color: white;");
        imagePop.getContent().add(vbox);

        view = new ImageView();
        view.setFitWidth(500);
        view.setFitHeight(500);
        vbox.getChildren().add(view);

        text = new Text();
        text.setStyle("-fx-font-size: 1.2em;");

        vbox.getChildren().add(text);
        vbox.setPadding(new Insets(15, 15, 15, 15));

    } catch (Exception e) {
        logger.debug(e.toString());
    }
}
 
Example #18
Source File: PopOver.java    From logbook-kai with MIT License 5 votes vote down vote up
/**
 * ポップアップを初期化します
 *
 * @param anchorNode アンカーノード
 * @return ポップアップ
 */
protected Popup initPopup(Node anchorNode) {
    Parent node = this.nodeSupplier.apply(anchorNode, this.userData.get(anchorNode));
    node.setOnMouseExited(this::setOnMouseExited);
    this.popup.getScene().setRoot(node);
    return this.popup;
}
 
Example #19
Source File: GenerateCodeDialog.java    From tcMenu with Apache License 2.0 5 votes vote down vote up
private void selectPlugin(List<CodePluginItem> pluginItems, String changeWhat, Consumer<CodePluginItem> eventHandler) {

        Popup popup = new Popup();
        List<UICodePluginItem> listOfComponents = pluginItems.stream()
                .map(display -> {
                    var it = new UICodePluginItem(manager, display, SELECT, item -> {
                        popup.hide();
                        eventHandler.accept(item);
                    });
                    it.setId("sel-" + display.getId());

                    return it;
                })
                .collect(Collectors.toList());

        VBox vbox = new VBox(5);
        addTitleLabel(vbox, "Select the " + changeWhat + " to use:");
        vbox.getChildren().addAll(listOfComponents);
        vbox.setPrefSize(700, 600);

        BorderPane pane = new BorderPane();
        pane.setCenter(vbox);
        vbox.getStyleClass().add("popupWindow");

        popup.getContent().add(pane);
        popup.setAutoHide(true);
        popup.setOnAutoHide(event -> popup.hide());
        popup.setHideOnEscape(true);
        popup.show(dialogStage);
    }
 
Example #20
Source File: Notifications.java    From oim-fx with MIT License 5 votes vote down vote up
@Override
protected void interpolate(double frac) {
    Popup popup = popupWeakReference.get();
    if (popup != null) {
        double newAnchorY = oldAnchorY + distance * frac;
        popup.setAnchorY(newAnchorY);
    }
}
 
Example #21
Source File: Notifications.java    From yfiton with Apache License 2.0 4 votes vote down vote up
private void removePopupFromMap(Pos p, Popup popup) {
    if (popupsMap.containsKey(p)) {
        List<Popup> popups = popupsMap.get(p);
        popups.remove(popup);
    }
}
 
Example #22
Source File: PopOver.java    From logbook-kai with MIT License 4 votes vote down vote up
/**
 * ポップアップの表示位置を設定します
 *
 * @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);
}
 
Example #23
Source File: Notification.java    From Enzo with Apache License 2.0 4 votes vote down vote up
/**
 * Creates and shows a popup with the data from the given Notification object
 * @param NOTIFICATION
 */
private void showPopup(final Notification NOTIFICATION) {
    Label title = new Label(NOTIFICATION.TITLE);
    title.getStyleClass().add("title");

    ImageView icon = new ImageView(NOTIFICATION.IMAGE);
    icon.setFitWidth(ICON_WIDTH);
    icon.setFitHeight(ICON_HEIGHT);

    Label message = new Label(NOTIFICATION.MESSAGE, icon);
    message.getStyleClass().add("message");

    VBox popupLayout = new VBox();
    popupLayout.setSpacing(10);
    popupLayout.setPadding(new Insets(10, 10, 10, 10));
    popupLayout.getChildren().addAll(title, message);

    StackPane popupContent = new StackPane();
    popupContent.setPrefSize(width, height);
    popupContent.getStyleClass().add("notification");
    popupContent.getChildren().addAll(popupLayout);

    final Popup POPUP = new Popup();
    POPUP.setX( getX() );
    POPUP.setY( getY() );
    POPUP.getContent().add(popupContent);

    popups.add(POPUP);

    // Add a timeline for popup fade out
    KeyValue fadeOutBegin = new KeyValue(POPUP.opacityProperty(), 1.0);
    KeyValue fadeOutEnd   = new KeyValue(POPUP.opacityProperty(), 0.0);

    KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin);
    KeyFrame kfEnd   = new KeyFrame(Duration.millis(500), fadeOutEnd);

    Timeline timeline = new Timeline(kfBegin, kfEnd);
    timeline.setDelay(popupLifetime);
    timeline.setOnFinished(actionEvent -> Platform.runLater(() -> {
        POPUP.hide();
        popups.remove(POPUP);
    }));

    // Move popup to the right during fade out
    //POPUP.opacityProperty().addListener((observableValue, oldOpacity, opacity) -> popup.setX(popup.getX() + (1.0 - opacity.doubleValue()) * popup.getWidth()) );

    if (stage.isShowing()) {
        stage.toFront();
    } else {
        stage.show();
    }

    POPUP.show(stage);
    timeline.play();
}
 
Example #24
Source File: Notifications.java    From yfiton with Apache License 2.0 4 votes vote down vote up
private void removePopupFromMap(Pos p, Popup popup) {
    if (popupsMap.containsKey(p)) {
        List<Popup> popups = popupsMap.get(p);
        popups.remove(popup);
    }
}
 
Example #25
Source File: Notifications.java    From yfiton with Apache License 2.0 4 votes vote down vote up
private void hide(Popup popup, Pos p) {
    popup.hide();
    removePopupFromMap(p, popup);
}
 
Example #26
Source File: PersonsCellFactory.java    From examples-javafx-repos1 with Apache License 2.0 4 votes vote down vote up
@Override
 public TableCell<Person, String> call(TableColumn<Person, String> param) {

     return new TextFieldTableCell<Person, String>(new DefaultStringConverter()) {      
     	
     	{
         	ContextMenu cm = new ContextMenu();
         	MenuItem deletePersonsMenuItem = new MenuItem("Delete");
         	deletePersonsMenuItem.setOnAction( PersonsCellFactory.this.deletePersonsHandler );
         	cm.getItems().add(deletePersonsMenuItem);
         	this.setContextMenu(cm);      
     	}
     	
         @Override
         public void updateItem(String arg0, boolean empty) {
         	
             super.updateItem(arg0, empty);
             
             if( !empty ) {
                 this.setText( arg0 );
             } else {
                 this.setText( null );  // clear from recycled obj
             }
         }

@SuppressWarnings("unchecked")
@Override
public void commitEdit(String newValue) {
	super.commitEdit(newValue);
	TableRow<Person> row = this.getTableRow();
	Person p = row.getItem();
	
	String msg = p.validate();
	if( logger.isLoggable(Level.FINE) ) {
		logger.fine("[COMMIT EDIT] validate=" + msg);
	}
		
	if( msg == null || msg.isEmpty() ) {
		if( logger.isLoggable(Level.FINE) ) {
			logger.fine("[COMMIT EDIT] validation passed");
		}
		Task<Void> task = new Task<Void>() {
			@Override
			protected Void call() {
				dao.updatePerson(p);  // updates AR too
				return null;
			}
		};
		new Thread(task).start();
	} else {
		
		System.out.println("layoutBounds=" + this.getLayoutBounds());
		System.out.println("boundsInLocal=" + this.getBoundsInLocal());
		System.out.println("boundsInParent=" + this.getBoundsInParent());
		System.out.println("boundsInParent (Scene)=" + this.localToScene(this.getBoundsInParent()));
		System.out.println("boundsInParent (Screen)=" + this.localToScreen(this.getBoundsInParent()));

		System.out.println("row layoutBounds=" + row.getLayoutBounds());
		System.out.println("row boundsInLocal=" + row.getBoundsInLocal());
		System.out.println("row boundsInParent=" + row.getBoundsInParent());
		System.out.println("row boundsInParent (Scene)=" + row.localToScene(this.getBoundsInParent()));
		System.out.println("row boundsInParent (Screen)=" + row.localToScreen(this.getBoundsInParent()));

		VBox vbox = new VBox();
		vbox.setPadding(new Insets(10.0d));
		vbox.setStyle("-fx-background-color: white; -fx-border-color: red");
		vbox.getChildren().add( new Label(msg));
		//vbox.setEffect(new DropShadow());
		
		Popup popup = new Popup();
		popup.getContent().add( vbox );
		popup.setAutoHide(true);
		popup.setOnShown((evt) -> {
			
			System.out.println("vbox layoutBounds=" + vbox.getLayoutBounds());
			System.out.println("vbox boundsInLocal=" + vbox.getBoundsInLocal());
			System.out.println("vbox boundsInParent=" + vbox.getBoundsInParent());
			System.out.println("vbox boundsInParent (Scene)=" + vbox.localToScene(this.getBoundsInParent()));
			System.out.println("vbox boundsInParent (Screen)=" + vbox.localToScreen(this.getBoundsInParent()));

		});
		popup.show( row, 
				row.localToScreen(row.getBoundsInParent()).getMinX(), 
				row.localToScreen(row.getBoundsInParent()).getMaxY());					
	}
}
     };
 }
 
Example #27
Source File: PersonTypeCellFactory.java    From examples-javafx-repos1 with Apache License 2.0 4 votes vote down vote up
@Override
 public TableCell<Person, String> call(TableColumn<Person, String> param) {

     return new ComboBoxTableCell<Person, String>(new DefaultStringConverter()) {      
     	
     	{
         	ContextMenu cm = new ContextMenu();
         	MenuItem deletePersonsMenuItem = new MenuItem("Delete");
         	deletePersonsMenuItem.setOnAction( PersonTypeCellFactory.this.deletePersonsHandler );
         	cm.getItems().add(deletePersonsMenuItem);
         	this.setContextMenu(cm);    
         	
         	this.getItems().addAll( "Friend", "Co-worker", "Other" );
         	
         	this.setEditable(true);
     	}
     	
         @Override
         public void updateItem(String arg0, boolean empty) {
         	
             super.updateItem(arg0, empty);
             
             if( !empty ) {
                 this.setText( arg0 );
             } else {
                 this.setText( null );  // clear from recycled obj
             }
         }

@SuppressWarnings("unchecked")
@Override
public void commitEdit(String newValue) {
	super.commitEdit(newValue);
	TableRow<Person> row = this.getTableRow();
	Person p = row.getItem();
	
	String msg = p.validate();
	if( logger.isLoggable(Level.FINE) ) {
		logger.fine("[COMMIT EDIT] validate=" + msg);
	}
		
	if( msg == null || msg.isEmpty() ) {
		if( logger.isLoggable(Level.FINE) ) {
			logger.fine("[COMMIT EDIT] validation passed");
		}
		Task<Void> task = new Task<Void>() {
			@Override
			protected Void call() {
				dao.updatePerson(p);  // updates AR too
				return null;
			}
		};
		new Thread(task).start();
	} else {
		
		System.out.println("layoutBounds=" + this.getLayoutBounds());
		System.out.println("boundsInLocal=" + this.getBoundsInLocal());
		System.out.println("boundsInParent=" + this.getBoundsInParent());
		System.out.println("boundsInParent (Scene)=" + this.localToScene(this.getBoundsInParent()));
		System.out.println("boundsInParent (Screen)=" + this.localToScreen(this.getBoundsInParent()));

		System.out.println("row layoutBounds=" + row.getLayoutBounds());
		System.out.println("row boundsInLocal=" + row.getBoundsInLocal());
		System.out.println("row boundsInParent=" + row.getBoundsInParent());
		System.out.println("row boundsInParent (Scene)=" + row.localToScene(this.getBoundsInParent()));
		System.out.println("row boundsInParent (Screen)=" + row.localToScreen(this.getBoundsInParent()));

		VBox vbox = new VBox();
		vbox.setPadding(new Insets(10.0d));
		vbox.setStyle("-fx-background-color: white; -fx-border-color: red");
		vbox.getChildren().add( new Label(msg));
		//vbox.setEffect(new DropShadow());
		
		Popup popup = new Popup();
		popup.getContent().add( vbox );
		popup.setAutoHide(true);
		popup.setOnShown((evt) -> {
			
			System.out.println("vbox layoutBounds=" + vbox.getLayoutBounds());
			System.out.println("vbox boundsInLocal=" + vbox.getBoundsInLocal());
			System.out.println("vbox boundsInParent=" + vbox.getBoundsInParent());
			System.out.println("vbox boundsInParent (Scene)=" + vbox.localToScene(this.getBoundsInParent()));
			System.out.println("vbox boundsInParent (Screen)=" + vbox.localToScreen(this.getBoundsInParent()));

		});
		popup.show( row, 
				row.localToScreen(row.getBoundsInParent()).getMinX(), 
				row.localToScreen(row.getBoundsInParent()).getMaxY());					
	}
}
     };
 }
 
Example #28
Source File: DockPane.java    From DockFX with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new DockPane adding event handlers for dock events and creating the indicator
 * overlays.
 */
public DockPane() {
  super();
  DockPane.dockPanes.add(this);

  this.addEventHandler(DockEvent.ANY, this);
  this.addEventFilter(DockEvent.ANY, new EventHandler<DockEvent>() {

    @Override
    public void handle(DockEvent event) {

      if (event.getEventType() == DockEvent.DOCK_ENTER) {
        DockPane.this.receivedEnter = true;
      } else if (event.getEventType() == DockEvent.DOCK_OVER) {
        DockPane.this.dockNodeDrag = null;
      }
    }

  });

  dockIndicatorPopup = new Popup();
  dockIndicatorPopup.setAutoFix(false);

  dockIndicatorOverlay = new Popup();
  dockIndicatorOverlay.setAutoFix(false);

  StackPane dockRootPane = new StackPane();
  dockRootPane.prefWidthProperty().bind(this.widthProperty());
  dockRootPane.prefHeightProperty().bind(this.heightProperty());

  dockAreaIndicator = new Rectangle();
  dockAreaIndicator.setManaged(false);
  dockAreaIndicator.setMouseTransparent(true);

  dockAreaStrokeTimeline = new Timeline();
  dockAreaStrokeTimeline.setCycleCount(Timeline.INDEFINITE);
  // 12 is the cumulative offset of the stroke dash array in the default.css style sheet
  // RFE filed for CSS styled timelines/animations:
  // https://bugs.openjdk.java.net/browse/JDK-8133837
  KeyValue kv = new KeyValue(dockAreaIndicator.strokeDashOffsetProperty(), 12);
  KeyFrame kf = new KeyFrame(Duration.millis(500), kv);
  dockAreaStrokeTimeline.getKeyFrames().add(kf);
  dockAreaStrokeTimeline.play();

  DockPosButton dockCenter = new DockPosButton(false, DockPos.CENTER);
  dockCenter.getStyleClass().add("dock-center");

  DockPosButton dockTop = new DockPosButton(false, DockPos.TOP);
  dockTop.getStyleClass().add("dock-top");
  DockPosButton dockRight = new DockPosButton(false, DockPos.RIGHT);
  dockRight.getStyleClass().add("dock-right");
  DockPosButton dockBottom = new DockPosButton(false, DockPos.BOTTOM);
  dockBottom.getStyleClass().add("dock-bottom");
  DockPosButton dockLeft = new DockPosButton(false, DockPos.LEFT);
  dockLeft.getStyleClass().add("dock-left");

  DockPosButton dockTopRoot = new DockPosButton(true, DockPos.TOP);
  StackPane.setAlignment(dockTopRoot, Pos.TOP_CENTER);
  dockTopRoot.getStyleClass().add("dock-top-root");

  DockPosButton dockRightRoot = new DockPosButton(true, DockPos.RIGHT);
  StackPane.setAlignment(dockRightRoot, Pos.CENTER_RIGHT);
  dockRightRoot.getStyleClass().add("dock-right-root");

  DockPosButton dockBottomRoot = new DockPosButton(true, DockPos.BOTTOM);
  StackPane.setAlignment(dockBottomRoot, Pos.BOTTOM_CENTER);
  dockBottomRoot.getStyleClass().add("dock-bottom-root");

  DockPosButton dockLeftRoot = new DockPosButton(true, DockPos.LEFT);
  StackPane.setAlignment(dockLeftRoot, Pos.CENTER_LEFT);
  dockLeftRoot.getStyleClass().add("dock-left-root");

  // TODO: dockCenter goes first when tabs are added in a future version
  dockPosButtons = FXCollections.observableArrayList(dockTop, dockRight, dockBottom, dockLeft,
      dockTopRoot, dockRightRoot, dockBottomRoot, dockLeftRoot);

  dockPosIndicator = new GridPane();
  dockPosIndicator.add(dockTop, 1, 0);
  dockPosIndicator.add(dockRight, 2, 1);
  dockPosIndicator.add(dockBottom, 1, 2);
  dockPosIndicator.add(dockLeft, 0, 1);
  // dockPosIndicator.add(dockCenter, 1, 1);

  dockRootPane.getChildren().addAll(dockAreaIndicator, dockTopRoot, dockRightRoot, dockBottomRoot,
      dockLeftRoot);

  dockIndicatorOverlay.getContent().add(dockRootPane);
  dockIndicatorPopup.getContent().addAll(dockPosIndicator);

  this.getStyleClass().add("dock-pane");
  dockRootPane.getStyleClass().add("dock-root-pane");
  dockPosIndicator.getStyleClass().add("dock-pos-indicator");
  dockAreaIndicator.getStyleClass().add("dock-area-indicator");
}
 
Example #29
Source File: Notifications.java    From yfiton with Apache License 2.0 4 votes vote down vote up
private void hide(Popup popup, Pos p) {
    popup.hide();
    removePopupFromMap(p, popup);
}
 
Example #30
Source File: BaseController.java    From MyBox with Apache License 2.0 4 votes vote down vote up
public void setPopup(Popup popup) {
    this.popup = popup;
}