import javafx.application.Application; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TitledPane; import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.stage.Modality; import javafx.stage.Stage; import javafx.stage.StageStyle; public class DialogTest extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(final Stage stage) throws Exception { stage.setTitle("Dialog Test"); stage.centerOnScreen(); final FlowPane root = new FlowPane(); final Scene scene = new Scene(root, 480, 412); Button button = new Button("Click"); root.getChildren().addAll(new Label("Label 1"), new Label("Label 2"), button); stage.setScene(scene); stage.show(); button.setOnAction(new EventHandler() { @Override public void handle(ActionEvent event) { Platform.runLater(new Runnable() { @Override public void run() { Stage dialog = new Stage(StageStyle.UNDECORATED); dialog.setOpacity(0.7D); dialog.initOwner(stage); dialog.initModality(Modality.APPLICATION_MODAL); dialog.setWidth(stage.getWidth()); dialog.setHeight(stage.getHeight()); dialog.setX(stage.getX()); dialog.setY(stage.getY()); HBox dialogRoot = new HBox(); dialogRoot.setFillHeight(true); dialogRoot.setAlignment(Pos.CENTER); TitledPane subDialog = new TitledPane("Teste", new Label("Content")); dialogRoot.getChildren().add(subDialog); dialog.show(); Scene dialogScene = new Scene(dialogRoot); dialogScene.setFill(Color.gray(0.5D)); dialog.setScene(dialogScene); } }); } }); } }