summaryrefslogtreecommitdiff
path: root/Java-Kompendium/kap17/src/main/java/Hinweis.java
blob: 0cf27668d2e874246d8cffe159238fa9463d7534 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.stage.Modality;
import javafx.stage.Stage;

public class Hinweis {
    public static void ausgeben(Stage fenster, String text) {
        GridPane grid = new GridPane();
        grid.setAlignment(Pos.CENTER);
        grid.setHgap(10);
        grid.setVgap(10);
        grid.setPadding(new Insets(10, 10, 10, 10));

        Scene scene = new Scene(grid, 300, 200);
        Label label = new Label(text);
        Button btn = new Button("OK");
        grid.add(label, 0, 0);
        grid.add(btn, 0, 1);
        Stage hinweisfenster = new Stage();
        hinweisfenster.initModality(Modality.WINDOW_MODAL);
        hinweisfenster.initOwner(fenster);
        hinweisfenster.setX(fenster.getX() + 30);
        hinweisfenster.setY(fenster.getY() + 30);
        hinweisfenster.setScene(scene);
        hinweisfenster.show();
        btn.setOnAction(new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent e) {
                hinweisfenster.close();
            }
        });
    }
}