java.lang.Object
no.ntnu.principes.controller.StageManager
Manages JavaFX Stage instances through their StageController wrappers.
Provides centralized access to named stages and coordinates their behavior.
Implemented as a singleton to ensure a single point of management for all application stages.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionStageManager(double width, double height) Creates a new StageManager with specified window dimensions. -
Method Summary
Modifier and TypeMethodDescriptiongetController(String name) Gets a StageController by name, creating a new one if it doesn't exist.getController(String name, double width, double height) Gets a StageController by name with custom dimensions, creating a new one if it doesn't exist.getController(String name, javafx.stage.Stage stage, double width, double height, boolean isUtility) Gets a StageController by name with custom parameters, creating a new one if it doesn't exist.static StageManagerGets the singleton instance of StageManager.getMainController(javafx.stage.Stage stage) Gets the main StageController, creating it if it doesn't exist.getUtilityController(String name, double width, double height) Gets a utility StageController by name, creating a new one if it doesn't exist.booleanhasController(String name) Checks if a StageController with the given name exists.voidremoveController(String name) Removes a StageController by name, closing its stage and cleaning up resources.
-
Field Details
-
MAIN_STAGE_NAME
- See Also:
-
-
Constructor Details
-
StageManager
public StageManager(double width, double height) Creates a new StageManager with specified window dimensions.- Parameters:
width- Initial default width for new stagesheight- Initial default height for new stages
-
-
Method Details
-
getInstance
Gets the singleton instance of StageManager.- Returns:
- The StageManager instance with default dimensions
-
getController
Gets a StageController by name, creating a new one if it doesn't exist. Uses default dimensions and a new Stage.- Parameters:
name- The unique name for the controller- Returns:
- The existing or newly created StageController
-
hasController
Checks if a StageController with the given name exists.- Parameters:
name- The name to check- Returns:
- true if a controller with that name exists, false otherwise
-
getController
public StageController getController(String name, javafx.stage.Stage stage, double width, double height, boolean isUtility) Gets a StageController by name with custom parameters, creating a new one if it doesn't exist.- Parameters:
name- The unique name for the controllerstage- The JavaFX Stage to usewidth- The width for the stageheight- The height for the stageisUtility- Whether this is a utility stage- Returns:
- The existing or newly created StageController
-
getController
Gets a StageController by name with custom dimensions, creating a new one if it doesn't exist. Uses a new Stage.- Parameters:
name- The unique name for the controllerwidth- The width for the stageheight- The height for the stage- Returns:
- The existing or newly created StageController
-
getUtilityController
Gets a utility StageController by name, creating a new one if it doesn't exist. Utility stages have different behavior than regular stages.- Parameters:
name- The unique name for the controllerwidth- The width for the stageheight- The height for the stage- Returns:
- The existing or newly created utility StageController
-
getMainController
Gets the main StageController, creating it if it doesn't exist. The main stage has special handling for application-wide stage events: - It closes all other stages when closed - It hides/shows all other stages when hidden/shown- Parameters:
stage- The JavaFX Stage to use as the main stage- Returns:
- The main StageController
-
removeController
Removes a StageController by name, closing its stage and cleaning up resources.- Parameters:
name- The name of the controller to remove
-