Class StageController

java.lang.Object
no.ntnu.principes.controller.StageController

public class StageController extends Object
Controls a JavaFX Stage with screen management capabilities. Handles stage configuration, theme switching, event handlers, and global keyboard shortcuts. Each StageController manages one Stage and its associated ScreenController.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StageController(String name, double width, double height)
    Creates a new StageController with a new Stage.
    StageController(String name, javafx.stage.Stage stage, double width, double height)
    Creates a new StageController with an existing Stage.
    StageController(String name, javafx.stage.Stage stage, double width, double height, boolean isUtility)
    Creates a new StageController with an existing Stage and utility flag.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes the stage, its screen controller, and tears down event handlers.
    boolean
    Checks if this is the main stage.
    void
    Registers all available screens with the ScreenController.
    void
    setWindowHeight(double windowHeight)
    Sets the window height and updates the stage accordingly.
    void
    setWindowWidth(double windowWidth)
    Sets the window width and updates the stage accordingly.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • StageController

      public StageController(String name, double width, double height)
      Creates a new StageController with a new Stage.
      Parameters:
      name - The name used to identify this controller
      width - The initial width of the stage
      height - The initial height of the stage
    • StageController

      public StageController(String name, javafx.stage.Stage stage, double width, double height)
      Creates a new StageController with an existing Stage.
      Parameters:
      name - The name used to identify this controller
      stage - The JavaFX Stage to be managed
      width - The initial width of the stage
      height - The initial height of the stage
    • StageController

      public StageController(String name, javafx.stage.Stage stage, double width, double height, boolean isUtility)
      Creates a new StageController with an existing Stage and utility flag.
      Parameters:
      name - The name used to identify this controller
      stage - The JavaFX Stage to be managed
      width - The initial width of the stage
      height - The initial height of the stage
      isUtility - Whether this stage is a utility stage (affects behavior)
  • Method Details

    • registerScreens

      public void registerScreens()
      Registers all available screens with the ScreenController. Uses ScreenRegistry to automatically find and register screens.
    • setWindowHeight

      public void setWindowHeight(double windowHeight)
      Sets the window height and updates the stage accordingly.
      Parameters:
      windowHeight - The new window height
    • setWindowWidth

      public void setWindowWidth(double windowWidth)
      Sets the window width and updates the stage accordingly.
      Parameters:
      windowWidth - The new window width
    • isMainStage

      public boolean isMainStage()
      Checks if this is the main stage.
      Returns:
      true if this is the main stage, false otherwise
    • close

      public void close()
      Closes the stage, its screen controller, and tears down event handlers. Performs cleanup operations for proper resource management.