-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainMenu.java
51 lines (43 loc) · 1.25 KB
/
MainMenu.java
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
package application;
import java.io.IOException;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
/**
* Controller class for the main menu.
*/
public class MainMenu {
@FXML GridPane _rootPane;
/**
* This method changes to the mic testing pane when the button is pressed
*/
@FXML public void micTestButton() throws IOException {
//Change to mic test pane
switchScenes("MicTesting.fxml");
}
/**
* This method changes to the practice recording screen when the button is pressed
*/
@FXML public void practiceButton() throws IOException {
//Change to practice pane
switchScenes("chooseRecordings.fxml");
}
/**
* This method switches scenes, given an fxml file name
* @param fxml the name of the fxml file
* @throws IOException
*/
public void switchScenes(String fxml) throws IOException {
//use fxmlloader to change the fxml file
Parent pane = FXMLLoader.load(getClass().getResource(fxml));
Stage stage = (Stage) _rootPane.getScene().getWindow();
Scene scene = stage.getScene();
//change and show the scene
scene = new Scene(pane);
stage.setScene(scene);
stage.sizeToScene();
}
}