Java Code Examples for javafx.scene.layout.VBox#setPadding()

The following examples show how to use javafx.scene.layout.VBox#setPadding() . 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: Main.java    From UltimateCore with MIT License 6 votes vote down vote up
public void showErrorMessage(String message) {
    final Stage window = new Stage();

    //Block events to other windows
    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle("UltimateCore");
    window.setWidth(250);
    window.setResizable(false);

    Label label = new Label();
    label.setText(message);
    Button close = new Button("Close");
    close.getStyleClass().add("button-close");
    close.setOnAction(t -> window.close());

    VBox layout = new VBox(10);
    layout.getChildren().addAll(label, close);
    layout.setAlignment(Pos.CENTER);
    layout.setPadding(new Insets(10, 10, 10, 10));

    //Display window and wait for it to be closed before returning
    Scene scene = new Scene(layout);
    scene.getStylesheets().add("assets/ultimatecore/style.css");
    window.setScene(scene);
    window.showAndWait();
}
 
Example 2
Source File: KpiDashboard.java    From medusademo with Apache License 2.0 6 votes vote down vote up
@Override public void init() {
    Label title = new Label("December 2015");
    title.setFont(Font.font(24));

    revenue = getBulletChart("Revenue", "($'000)", 600, 500, new Section(0, 200, RED), new Section(200, 400, YELLOW), new Section(400, 600, GREEN));
    profit  = getBulletChart("Profit", "($'000)", 100, 70, new Section(0, 20, RED), new Section(20, 60, YELLOW), new Section(60, 100, GREEN));
    sales   = getBulletChart("Sales", "(unit)", 1000, 700, new Section(0, 300, RED), new Section(300, 500, YELLOW), new Section(500, 1000, GREEN));

    HBox legend = new HBox(getLegendBox(RED, "Poor", 10),
                           getLegendBox(YELLOW, "Average", 10),
                           getLegendBox(GREEN, "Good", 10),
                           getLegendBox(GRAY, "Target", 5));
    legend.setSpacing(20);
    legend.setAlignment(Pos.CENTER);

    pane = new VBox(title, revenue, profit, sales, legend);
    pane.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
    pane.setPadding(new Insets(20, 20, 20, 20));
    pane.setSpacing(10);
}
 
Example 3
Source File: HtmlWebView.java    From Learn-Java-12-Programming with MIT License 6 votes vote down vote up
public void start9(Stage primaryStage) {
    try {
        Text txt = new Text("Fill the form and click Submit");

        WebView wv = new WebView();
        WebEngine we = wv.getEngine();
        File f = new File("src/main/resources/form.html");
        we.load(f.toURI().toString());

        VBox vb = new VBox(txt, wv);
        vb.setSpacing(10);
        vb.setAlignment(Pos.CENTER);
        vb.setPadding(new Insets(10, 10, 10, 10));

        Scene scene = new Scene(vb, 300, 200);

        primaryStage.setScene(scene);
        primaryStage.setTitle("JavaFX with embedded HTML");
        primaryStage.onCloseRequestProperty()
                .setValue(e -> System.out.println("Bye! See you later!"));
        primaryStage.show();
    } catch (Exception ex){
        ex.printStackTrace();
    }
}
 
Example 4
Source File: HtmlWebView.java    From Learn-Java-12-Programming with MIT License 6 votes vote down vote up
public void start8(Stage primaryStage) {
    try {
        Text txt = new Text("Below is the embedded HTML:");

        WebView wv = new WebView();
        WebEngine we = wv.getEngine();
        String html = "<html><center><h2>Hello, world!</h2></center></html>";
        we.loadContent(html, "text/html");

        VBox vb = new VBox(txt, wv);
        vb.setSpacing(10);
        vb.setAlignment(Pos.CENTER);
        vb.setPadding(new Insets(10, 10, 10, 10));

        Scene scene = new Scene(vb, 300, 120);

        primaryStage.setScene(scene);
        primaryStage.setTitle("JavaFX with embedded HTML");
        primaryStage.onCloseRequestProperty()
                .setValue(e -> System.out.println("Bye! See you later!"));
        primaryStage.show();
    } catch (Exception ex){
        ex.printStackTrace();
    }
}
 
Example 5
Source File: ErrLogInstance.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
public ErrLogInstance(final AppDescriptor app) throws Exception
{
    this.app = app;

    line_view = new LineView();

    errlog = new ErrLog(out -> line_view.addLine(out,  false),
                        err -> line_view.addLine(err, true));

    final VBox layout = new VBox(line_view.getControl());
    VBox.setVgrow(line_view.getControl(), Priority.ALWAYS);
    layout.setPadding(new Insets(5.0));
    tab = new DockItem(this, layout);
    tab.addCloseCheck(() ->
    {
        errlog.close();
        INSTANCE = null;
        return true;
    });
    DockPane.getActiveDockPane().addTab(tab);
}
 
Example 6
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@NotNull
private static VBox getTopLabelVBox(int top) {
    VBox vBox = new VBox();
    vBox.setSpacing(0);
    vBox.setPadding(new Insets(top, 0, 0, 0));
    vBox.setAlignment(Pos.CENTER_LEFT);
    return vBox;
}
 
Example 7
Source File: ReplayStage.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
protected VBox getVBox ()
{
  VBox vbox = new VBox ();
  vbox.setSpacing (15);
  vbox.setPadding (new Insets (10, 10, 10, 10));              // trbl
  return vbox;
}
 
Example 8
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 9
Source File: DirectionsPane.java    From FXMaps with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Constructs a new {@code DirectionsPane}
 */
public DirectionsPane() {
    directionsBox = new VBox();
    directionsBox.setPadding(new Insets(5,5,5,5));
    
    setHbarPolicy(ScrollBarPolicy.NEVER);
    setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
    setStyle("-fx-background-fill: rgb(255,255,255);");
     
    directionsBox.maxWidthProperty().bind(widthProperty().subtract(10));
    
    addDirectionsBulletinPane(bulletinText);
    
    setContent(directionsBox);
}
 
Example 10
Source File: ScheduleThemeNode.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
public ScheduleThemeNode(UpdateThemeCallback songCallback, UpdateThemeCallback bibleCallback, Stage popup, Button themeButton) {
    this.songCallback = songCallback;
    this.bibleCallback = bibleCallback;
    this.popup = popup;
    themeDialog = new EditThemeDialog();
    themeDialog.initModality(Modality.APPLICATION_MODAL);
    contentPanel = new VBox();
    BorderPane.setMargin(contentPanel, new Insets(10));
    themeButton.layoutXProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
            MainWindow mainWindow = QueleaApp.get().getMainWindow();
            double width = mainWindow.getWidth() - t1.doubleValue() - 100;
            if (width < 50) {
                width = 50;
            }
            if (width > 900) {
                width = 900;
            }
            contentPanel.setPrefWidth(width);
            contentPanel.setMaxWidth(width);
        }
    });
    setMaxHeight(300);
    contentPanel.setSpacing(5);
    contentPanel.setPadding(new Insets(3));
    refresh();
    ScrollPane scroller = new ScrollPane(contentPanel);
    scroller.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    setCenter(scroller);
}
 
Example 11
Source File: DemoView.java    From PreferencesFX with Apache License 2.0 5 votes vote down vote up
private void layoutParts() {
  // MenuBar
  menu.getItems().add(preferencesMenuItem);
  menuBar.getMenus().add(menu);

  // VBox with values
  VBox valueBox = new VBox(
      welcomeLbl,
      brightnessLbl,
      nightModeLbl,
      scalingLbl
  );
  valueBox.setSpacing(20);
  valueBox.setPadding(new Insets(20, 0, 0, 20));

  // VBox with descriptions
  VBox descriptionBox = new VBox(
      new Label("Welcome Text:"),
      new Label("Brightness:"),
      new Label("Night mode:"),
      new Label("Scaling:")
  );
  descriptionBox.setSpacing(20);
  descriptionBox.setPadding(new Insets(20, 0, 0, 20));

  // Put everything together
  getChildren().addAll(
      menuBar,
      new HBox(
          descriptionBox,
          valueBox
      )
  );

  // Styling
  getStyleClass().add("demo-view");
  if (rootPane.nightMode.get()) {
    getStylesheets().add(AppStarter.class.getResource("darkTheme.css").toExternalForm());
  }
}
 
Example 12
Source File: GuiFactory.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
public VBox getVBox()
{
  VBox vbox = new VBox(15.0D);
  
  vbox.setPadding(new Insets(10.0D, 10.0D, 10.0D, 10.0D));
  return vbox;
}
 
Example 13
Source File: UpdateProgressWindow.java    From HubTurbo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private VBox createDownloadProgressItem(LabeledDownloadProgressBar progressTracker) {
    Label downloadLabel = new Label();
    downloadLabel.setText(progressTracker.getDownloadLabel());

    ProgressBar progressBar = progressTracker.getProgressBar();

    VBox downloadProgressItem = new VBox();
    downloadProgressItem.setSpacing(20);
    downloadProgressItem.setPadding(new Insets(20));
    downloadProgressItem.setAlignment(Pos.CENTER_LEFT);

    downloadProgressItem.getChildren().addAll(downloadLabel, progressBar);

    return downloadProgressItem;
}
 
Example 14
Source File: ExpressionEvaluatorPopup.java    From arma-dialog-creator with MIT License 4 votes vote down vote up
public ExpressionEvaluatorPopup() {
	super(ArmaDialogCreator.getPrimaryStage(), new VBox(0), null);

	setTitle(bundle.getString("popup_title"));
	setStageSize(820, 550);

	taConsole.setText(bundle.getString("CodeArea.console_init") + " ");
	String[] commands = ExpressionInterpreter.getSupportedCommands();
	for (String command : commands) {
		taConsole.appendText(command != commands[commands.length - 1] ? command + ", " : command);
	}
	taConsole.appendText("\n\n");
	taConsole.setWrapText(true);

	//setup toolbar
	ToolBar toolBar;
	{
		btnEval = new Button(bundle.getString("Toolbar.evaluate"));
		btnEval.setOnAction(event -> evaluateText());

		btnTerminate = new Button(bundle.getString("Toolbar.terminate"));
		btnTerminate.setDisable(true);
		btnTerminate.setOnAction(event -> {
			activeEvaluateTask.cancel(true);
			btnTerminate.setDisable(false);
		});

		Button btnToggleConsole = new Button(bundle.getString("Toolbar.toggle_console"));
		btnToggleConsole.setOnAction(event -> toggleConsole());

		Button btnHelp = new Button(Lang.ApplicationBundle().getString("Popups.btn_help"));
		btnHelp.setOnAction(event -> help());

		toolBar = new ToolBar(
				btnEval, btnTerminate,
				new Separator(Orientation.VERTICAL),
				btnToggleConsole,
				new Separator(Orientation.VERTICAL),
				btnHelp
		);
	}

	myRootElement.getChildren().add(toolBar);

	//setup code area pane and environment overview
	VBox vboxAfterToolBar = new VBox(10);
	VBox.setVgrow(vboxAfterToolBar, Priority.ALWAYS);
	vboxAfterToolBar.setPadding(new Insets(10));
	vboxAfterToolBar.setMinWidth(300);
	VBox vboxEnvOverview = new VBox(5, new Label(bundle.getString("EnvOverview.label")), environmentOverviewPane);
	HBox hbox = new HBox(5, codeAreaPane, vboxEnvOverview);
	HBox.setHgrow(codeAreaPane, Priority.ALWAYS);
	HBox.setHgrow(vboxEnvOverview, Priority.SOMETIMES);

	VBox.setVgrow(hbox, Priority.ALWAYS);
	vboxAfterToolBar.getChildren().add(hbox);
	vboxAfterToolBar.getChildren().add(stackPaneConsole);

	vboxAfterToolBar.getChildren().add(new HBox(
			5,
			footerValueLabel(bundle.getString("CodeArea.return_value")), stackPaneResult,
			new Separator(Orientation.VERTICAL),
			footerValueLabel(bundle.getString("CodeArea.run_time")), stackPaneRunTime
	));

	ScrollPane scrollPane = new ScrollPane(vboxAfterToolBar);
	scrollPane.setFitToHeight(true);
	scrollPane.setFitToWidth(true);

	VBox.setVgrow(scrollPane, Priority.ALWAYS);

	myRootElement.getChildren().add(scrollPane);

}
 
Example 15
Source File: MessageItemRight.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	this.getChildren().add(rootPane);
	rootPane.setTop(timePane);
	rootPane.setLeft(leftBox);
	rootPane.setCenter(centerPane);
	rootPane.setRight(heahBox);
	
	leftBox.setPrefWidth(40);
	
	heahBox.setPrefHeight(20);
	timeLabel.setStyle("-fx-text-fill:#fff;"
			+ "-fx-background-color:#dadada;\r\n" + 
			"   -fx-background-radius:2;-fx-padding: 0 6px;");
	nameLabel.setStyle("-fx-text-fill:rgba(120, 120, 120, 1)");
	double value=38;
	Rectangle clip = new Rectangle();
	clip.setWidth(value);
	clip.setHeight(value);

	clip.setArcHeight(value);
	clip.setArcWidth(value);
	
	StackPane heahPane = new StackPane();
	heahPane.setClip(clip);
	heahPane.getChildren().add(headImageView);
	
	timePane.getChildren().add(timeLabel);
	heahBox.getChildren().add(heahPane);

	headImageView.setFitWidth(40);
	headImageView.setFitHeight(40);

	Polygon polygon = new Polygon(new double[] {

			0, 0,

			10, 10,

			0, 20,

	});

	polygon.setFill(Color.web("rgba(44, 217, 44, 1)"));
	//polygon.setStroke(Color.BLUE);
	//polygon.setStyle("-fx-background-color:rgba(245, 245, 245, 1);");
	VBox arrowBox = new VBox();
	arrowBox.setPadding(new Insets(3, 0, 0, 0));
	arrowBox.setAlignment(Pos.TOP_RIGHT);
	arrowBox.getChildren().add(polygon);
	
	contentBox.setStyle("-fx-background-color:rgba(44, 217, 44, 1);-fx-background-radius:3;");

	centerBox.setAlignment(Pos.CENTER_RIGHT);
	
	centerBox.getChildren().add(contentBox);
	centerBox.getChildren().add(arrowBox);
	
	HBox nameBox=new HBox();
	nameBox.setAlignment(Pos.TOP_RIGHT);
	nameBox.setPadding(new Insets(0, 10, 0, 10));
	nameBox.getChildren().add(nameLabel);
	
	centerPane.setTop(nameBox);
	centerPane.setCenter(centerBox);
}
 
Example 16
Source File: ChatTopPane.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	this.getChildren().add(baseBorderPane);

	nameLabel.setStyle("-fx-font-size:18px;");

	nameHBox.getChildren().add(nameLabel);
	textHBox.getChildren().add(textLabel);

	VBox infoVBox = new VBox();
	infoVBox.setPadding(new Insets(10, 0, 5, 28));
	infoVBox.getChildren().add(nameHBox);
	infoVBox.getChildren().add(textHBox);

	// this.setPadding(new Insets(0, 0, 0, 8));

	// textBox.setStyle("-fx-background-color:rgba(255, 255, 255, 0.92)");

	toolBar.setBackground(Background.EMPTY);
	//toolBar.setPadding(new Insets(0, 0, 0, 0));
	toolBar.setPadding(new Insets(0, 0, 0, 28));
	
	rightToolBox.setAlignment(Pos.CENTER_RIGHT);

	
	HBox toolHBox = new HBox();
	
	toolHBox.setAlignment(Pos.CENTER_LEFT);
	toolHBox.getChildren().add(toolBar);
	
	BorderPane toolBorderPane = new BorderPane();
	toolBorderPane.setStyle("-fx-background-color:rgba(255, 255, 255, 0.9)");
	toolBorderPane.setCenter(toolHBox);
	toolBorderPane.setRight(rightToolBox);
	
	HBox topLine = new HBox();
	topLine.setMinHeight(1);
	topLine.setStyle("-fx-background-color:#d6d6d6;");

	VBox topVBox = new VBox();
	topVBox.setPadding(new Insets(0, 0, 0, 0));
	topVBox.getChildren().add(infoVBox);
	topVBox.getChildren().add(topLine);
	
	baseBorderPane.setCenter(topVBox);
	baseBorderPane.setBottom(toolBorderPane);
}
 
Example 17
Source File: HTMLEditorSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public HTMLEditorSample() {
    VBox vRoot = new VBox();

    vRoot.setPadding(new Insets(8, 8, 8, 8));
    vRoot.setSpacing(5);

    htmlEditor = new HTMLEditor();
    htmlEditor.setPrefSize(500, 245);
    htmlEditor.setHtmlText(INITIAL_TEXT);
    vRoot.getChildren().add(htmlEditor);

    final Label htmlLabel = new Label();
    htmlLabel.setMaxWidth(500);
    htmlLabel.setWrapText(true);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setContent(htmlLabel);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefHeight(180);

    Button showHTMLButton = new Button("Show the HTML below");
    vRoot.setAlignment(Pos.CENTER);
    showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            htmlLabel.setText(htmlEditor.getHtmlText());
        }
    });

    vRoot.getChildren().addAll(showHTMLButton, scrollPane);
    getChildren().addAll(vRoot);

    // REMOVE ME
    // Workaround for RT-16781 - HTML editor in full screen has wrong border
    javafx.scene.layout.GridPane grid = (javafx.scene.layout.GridPane)htmlEditor.lookup(".html-editor");
    for(javafx.scene.Node child: grid.getChildren()) {
        javafx.scene.layout.GridPane.setHgrow(child, javafx.scene.layout.Priority.ALWAYS);
    }
    // END REMOVE ME
}
 
Example 18
Source File: HTMLEditorSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public HTMLEditorSample() {
    VBox vRoot = new VBox();

    vRoot.setPadding(new Insets(8, 8, 8, 8));
    vRoot.setSpacing(5);

    htmlEditor = new HTMLEditor();
    htmlEditor.setPrefSize(500, 245);
    htmlEditor.setHtmlText(INITIAL_TEXT);
    vRoot.getChildren().add(htmlEditor);

    final Label htmlLabel = new Label();
    htmlLabel.setMaxWidth(500);
    htmlLabel.setWrapText(true);

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.getStyleClass().add("noborder-scroll-pane");
    scrollPane.setContent(htmlLabel);
    scrollPane.setFitToWidth(true);
    scrollPane.setPrefHeight(180);

    Button showHTMLButton = new Button("Show the HTML below");
    vRoot.setAlignment(Pos.CENTER);
    showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent arg0) {
            htmlLabel.setText(htmlEditor.getHtmlText());
        }
    });

    vRoot.getChildren().addAll(showHTMLButton, scrollPane);
    getChildren().addAll(vRoot);

    // REMOVE ME
    // Workaround for RT-16781 - HTML editor in full screen has wrong border
    javafx.scene.layout.GridPane grid = (javafx.scene.layout.GridPane)htmlEditor.lookup(".html-editor");
    for(javafx.scene.Node child: grid.getChildren()) {
        javafx.scene.layout.GridPane.setHgrow(child, javafx.scene.layout.Priority.ALWAYS);
    }
    // END REMOVE ME
}
 
Example 19
Source File: DemoView.java    From PreferencesFX with Apache License 2.0 4 votes vote down vote up
private void layoutParts() {
  // MenuBar
  menu.getItems().add(preferencesMenuItem);
  menuBar.getMenus().add(menu);

  // VBox with values
  VBox valueBox = new VBox(
      welcomeLbl,
      brightnessLbl,
      nightModeLbl,
      scalingLbl,
      screenNameLbl,
      resolutionLbl,
      orientationLbl,
      favoritesLbl,
      fontSizeLbl,
      lineSpacingLbl,
      favoriteNumberLbl,
      englishBtn,
      germanBtn
  );
  valueBox.setSpacing(20);
  valueBox.setPadding(new Insets(20, 0, 0, 20));

  // VBox with descriptions
  VBox descriptionBox = new VBox(
      new Label("Welcome Text:"),
      new Label("Brightness:"),
      new Label("Night mode:"),
      new Label("Scaling:"),
      new Label("Screen name:"),
      new Label("Resolution:"),
      new Label("Orientation:"),
      new Label("Favorites:"),
      new Label("Font Size:"),
      new Label("Line Spacing:"),
      new Label("Favorite Number:")
  );
  descriptionBox.setSpacing(20);
  descriptionBox.setPadding(new Insets(20, 0, 0, 20));

  // Put everything together
  getChildren().addAll(
      menuBar,
      new HBox(
          descriptionBox,
          valueBox
      )
  );

  // Styling
  getStyleClass().add("demo-view");
  if (rootPane.nightMode.get()) {
    getStylesheets().add(AppStarter.class.getResource("darkTheme.css").toExternalForm());
  }
}
 
Example 20
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();
}