79374566

Date: 2025-01-21 13:26:21
Score: 0.5
Natty:
Report link

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());
        }
    }
}

enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Thomas