without size it also works only in KDE and older GNOME (22.04) and not in actual GNOME (24.04)
public class Muster extends Application {
private static Stage primary = null;
public static void main(String[] args) {
launch(args);
}
@Override
public void init() throws Exception {
}
@Override
public void start(Stage primaryStage) {
primary = primaryStage;
show(true, "Dialog 1", false);
}
private static void show(boolean first, String title, boolean wait) {
VBox vBox = new VBox(10);
vBox.setPadding(new Insets(25));
vBox.setAlignment(Pos.CENTER);
Button btnWait = new Button("Dialog wait");
btnWait.setOnAction(a -> show(false, "Wieder einer", true));
Button btn = new Button("Dialog");
btn.setOnAction(a -> show(false, "Wieder einer", false));
vBox.getChildren().add(new Label("Das ist ein Dialog"));
vBox.getChildren().addAll(btnWait, btn);
for (int i = 0; i < 10; ++i) {
HBox hBox = new HBox(10);
for (int ii = 0; ii < 10; ++ii) {
Text text = new Text("Nummer: " + ii);
Font font = Font.font("Verdana", FontWeight.BOLD, 16);
text.setFont(font);
hBox.getChildren().add(text);
}
vBox.getChildren().add(hBox);
}
try {
Stage stage = first ? primary : new Stage();
Scene scene = new Scene(vBox);
stage.setScene(scene);
stage.setTitle(title);
if (!first) {
stage.initOwner(primary);
}
stage.requestFocus();
stage.toFront();
if (wait) {
stage.showAndWait();
} else {
stage.show();
}
} catch (final Exception exc) {
System.out.println(exc.getMessage());
}
}
}