Newer
Older
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package userInterface;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.image.Image;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
public class Main extends Application
{
@Override
public void start(Stage stage)
{
try
{
FXMLLoader loader = new FXMLLoader(getClass().getResource("userInterface.fxml"));
Parent root = (Parent)loader.load();
Scene scene = new Scene(root, 800, 800);
stage.setResizable(false);
stage.setTitle("SmartTime");
stage.setScene(scene);
UserInterfaceController controller = (UserInterfaceController)loader.getController();
controller.setStage(stage);
controller.init();
stage.getIcons().add(new Image("/userInterface/icon.png"));
stage.show();
// fngt die Aufforderung das Fenster zu schlieen ab, um vorher
// noch eine Prfung duchzufhren
stage.setOnCloseRequest(new EventHandler<WindowEvent>()
{
public void handle(WindowEvent we)
{
if(controller.stoppUhrLuftFlag == true)
{
Alert alert = new Alert(AlertType.WARNING);
alert.setTitle("Warnung");
alert.setHeaderText("");
alert.setContentText("Stoppuhr luft noch!");
alert.showAndWait();
// "schluckt" die Aufforderung das Fenster zu schlieen
// (Fenster wird dadurch nicht geschlossen)
we.consume();
}
else
{
stage.close();
}
}
});
}
catch(Exception e)
{
e.printStackTrace();
}
}
public static void main(String[] args)
{
launch(args);
}
}