-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAlertBox.java
More file actions
32 lines (24 loc) · 847 Bytes
/
AlertBox.java
File metadata and controls
32 lines (24 loc) · 847 Bytes
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
import javafx.stage.*;
import javafx.scene.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
import javafx.geometry.*;
class AlertBox {
public static void display(String title, String message) {
Stage window = new Stage();
window.initModality(Modality.APPLICATION_MODAL);
window.setTitle(title);
window.setMinWidth(250);
Label label = new Label();
label.setText(message);
Button closeButton = new Button("Got it");
closeButton.setOnAction(e -> window.close());
VBox layout = new VBox(10);
layout.getChildren().addAll(label, closeButton);
layout.setAlignment(Pos.CENTER);
layout.setPadding(new Insets(20,20,20,20));
Scene scene = new Scene(layout);
window.setScene(scene);
window.showAndWait();
}
}