- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartSceneController.java
More file actions
Latest commit
49 lines (46 loc) · 1.77 KB
/
Copy pathStartSceneController.java
File metadata and controls
49 lines (46 loc) · 1.77 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
packagefinalProject;
importjava.io.IOException;
importjava.net.URL;
importjava.util.ResourceBundle;
importjavafx.event.ActionEvent;
importjavafx.fxml.FXML;
importjavafx.fxml.FXMLLoader;
importjavafx.fxml.Initializable;
importjavafx.scene.Node;
importjavafx.scene.Scene;
importjavafx.scene.control.Button;
importjavafx.scene.control.Slider;
importjavafx.stage.Stage;
publicclassStartSceneControllerimplementsInitializable{
@FXML
privateButtonternisButton;
@FXML
privateButtonmineSweeperButton;
@FXML
privateSliderdifficultSlider;
privatedoubledifficulty;
privateFXMLLoadergameLoader;
@Override
publicvoidinitialize(URLarg0,ResourceBundlearg1){
difficultSlider.valueProperty().addListener(e->difficulty=difficultSlider.getValue());
}
publicvoidternisStart(ActionEvente) throwsIOException{
Stagestage= (Stage)((Node)e.getSource()).getScene().getWindow();
gameLoader=newFXMLLoader(getClass().getResource("ternis.fxml"));
SceneternisScene=newScene(gameLoader.load(),300,500);
ternisControllercontroller=gameLoader.getController();
controller.difficulty=difficulty;
controller.Initialize(ternisScene);
stage.setTitle("tetris");
stage.setScene(ternisScene);
}
publicvoidminesweeperStart(ActionEvente) throwsIOException{
gameLoader=newFXMLLoader(getClass().getResource("minesweeper.fxml"));
SceneminesweeperScene=newScene(gameLoader.load(),800,600);
minesweeperControllercontroller=gameLoader.getController();
controller.difficulty=difficulty;
Stagestage= (Stage)((Node)e.getSource()).getScene().getWindow();
stage.setTitle("minesweeper");
stage.setScene(minesweeperScene);
}
}