# Class CloseStageManager

java.lang.Object
it.polimi.ingsw.is25am31.view.gui.CloseStageManager

public class CloseStageManager extends Object
Singleton manager for handling the closing of all application stages. Ensures proper cleanup and termination of the JavaFX application when any stage is closed.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addStage(javafx.stage.Stage stage)`
  Registers a stage with the manager and sets up its close request handler.
  `void`
  `closeAllStages()`
  Closes all managed stages that are currently showing.
  `void`
  `exitApplication()`
  Terminates the entire application.
  `static CloseStageManager`
  `getCloseStageManager()`
  Gets the singleton instance of CloseStageManager.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### getCloseStageManager

    public static CloseStageManager getCloseStageManager()
    Gets the singleton instance of CloseStageManager. Creates a new instance if one doesn't exist.
    Returns:
      the singleton instance of CloseStageManager

  - ### addStage

    public void addStage(javafx.stage.Stage stage)
    Registers a stage with the manager and sets up its close request handler. When the stage is closed, it will trigger the application exit process.
    Parameters:
      `stage` - the JavaFX stage to be managed

  - ### exitApplication

    public void exitApplication()
    Terminates the entire application. Shuts down the JavaFX platform and exits the JVM with status code 0.

  - ### closeAllStages

    public void closeAllStages()
    Closes all managed stages that are currently showing. Clears the list of managed stages after closing them.