-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSceneManager.java
More file actions
33 lines (28 loc) · 1.14 KB
/
SceneManager.java
File metadata and controls
33 lines (28 loc) · 1.14 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
// Author: Tytus Felbor
import java.util.HashMap;
import javafx.stage.Stage;
public class SceneManager {
// Enum to represent different types of scenes
protected static enum SceneType {Login, Home, Chat, Calculator, Stocks};
// HashMap to store scenes
protected static HashMap<SceneType, SceneTemplate> scenes = new HashMap<SceneType, SceneTemplate>();
// Stage to display scenes
protected static Stage stage;
// Constructor to initialize scenes
public SceneManager() {
scenes.put(SceneType.Login, new LoginScene());
scenes.put(SceneType.Home, new HomeScene());
scenes.put(SceneType.Chat, new ChatScene());
scenes.put(SceneType.Calculator, new CalculatorScene());
scenes.put(SceneType.Stocks, new StockScene());
}
// Set the stage to be used by all scenes
public static void setStage(Stage st) {
stage = st;
st.setResizable(false); // Make the stage not resizable
}
// Method to switch the view to the selected scene
public static void setScene(SceneType type) {
stage.setScene(scenes.get(type).getScene()); // Switch to the selected scene
}
}