-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppStarter.java
More file actions
61 lines (53 loc) · 2.04 KB
/
AppStarter.java
File metadata and controls
61 lines (53 loc) · 2.04 KB
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
package ch.fhnw.oop2.swissmountainsfx;
import ch.fhnw.oop2.swissmountainsfx.presentationmodel.MountainModel;
import ch.fhnw.oop2.swissmountainsfx.view.MountainUI;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ButtonType;
import javafx.scene.control.DialogPane;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
/**
* Starts the application.
*/
public class AppStarter extends Application {
/**
* (non-Javadoc)
* @see javafx.application.Application#start(javafx.stage.Stage)
*/
@Override
public void start(Stage primaryStage) throws Exception {
MountainModel pm = new MountainModel();
Parent rootPanel = new MountainUI(pm);
Scene scene = new Scene(rootPanel);
primaryStage.titleProperty().bind(pm.applicationTitleProperty());
primaryStage.setScene(scene);
primaryStage.getIcons().add(new Image("file:./src/main/java/ch/fhnw/oop2/swissmountainsfx/ownresources/swiss.jpg"));
primaryStage.setMinHeight(510);
primaryStage.setMinWidth(820);
primaryStage.show();
pm.setSelectedMountainID(pm.getData().get(0).getId());
primaryStage.setOnCloseRequest(e -> {
Alert alert = new Alert(AlertType.CONFIRMATION);
Image img = new Image("file:./src/main/java/ch/fhnw/oop2/swissmountainsfx/ownresources/cow.png");
ImageView imgView = new ImageView(img);
alert.setTitle("Swiss Mountain");
alert.setHeaderText("Close Swiss Mountain Application?");
alert.setContentText("Cheers Tabea & Benjamin");
alert.setGraphic(imgView);
alert.showAndWait().
filter(t -> t != ButtonType.OK).
ifPresent(t -> e.consume());
}
);
}
public static void main(String[] args) {
launch(args);
}
}