Class FrameManager<Key extends WindowInfo>

  • Type Parameters:
    Key - The class defining the window types (typically an enum)

    public class FrameManager<Key extends WindowInfo>
    extends java.lang.Object
    Manages an application's windows. This class creates window and initializes their menu bar with the Windows and Help menus. This class updates the Windows menu whenever another window is opened or closed. Typically, menu items for opening new windows are created using FrameAction. Non-singleton windows can be reused by overriding ApplicationWindowAction.matches(StatusFrame).
    • Field Detail

      • WINDOWS_MENU_KEY

        protected static final java.lang.String WINDOWS_MENU_KEY
        See Also:
        Constant Field Values
    • Constructor Detail

      • FrameManager

        public FrameManager​(java.util.ResourceBundle bundle,
                            java.util.function.Function<Key,​? extends java.awt.Container> singletonPanelSupplier,
                            java.util.Map<Key,​PanelFactory<? extends ApplicationWindowAction<Key>>> panelFactories,
                            java.util.function.Function<java.awt.Window,​java.awt.Dialog> aboutDialogSupplier)
        Create a FrameManager that uses default StatusFrames.
        Parameters:
        bundle - the ResourceBundle to use for localization of the windows
        singletonPanelSupplier - a function that returns the content panels of the singleton windows
        panelFactories - a map of the factories for the content panels of the non-singleton windows
        aboutDialogSupplier - a factory for creating the About dialog
      • FrameManager

        public FrameManager​(java.util.ResourceBundle bundle,
                            java.util.function.Function<Key,​? extends java.awt.Container> singletonPanelSupplier,
                            java.util.Map<Key,​PanelFactory<? extends ApplicationWindowAction<Key>>> panelFactories,
                            java.util.function.Function<java.awt.Window,​java.awt.Dialog> aboutDialogSupplier,
                            java.util.function.BiFunction<java.util.ResourceBundle,​java.lang.String,​StatusFrame> frameFactory)
        Create a FrameManager that uses custom StatusFrames.
        Parameters:
        bundle - the ResourceBundle to use for localization of the windows
        singletonPanelSupplier - a function that returns the content panels of the singleton windows
        panelFactories - a map of the factories for the content panels of the non-singleton windows
        aboutDialogSupplier - a factory for creating the About dialog
        frameFactory - a factory for creating StatusFrames for the windows
    • Method Detail

      • onWindowEvent

        public StatusFrame onWindowEvent​(ApplicationWindowAction<Key> action)
        Display a singleton window or create a new instance of a non-singleton window.
        Parameters:
        action - action describing the window
        Returns:
        the matching window
      • addSingletonFrame

        public void addSingletonFrame​(Key key,
                                      StatusFrame frame)
        Register a singleton window.
        Parameters:
        key - the window type
        frame - the window
        Throws:
        java.lang.IllegalArgumentException - if another window has already been registered for the specified key
      • showSingletonFrame

        public StatusFrame showSingletonFrame​(Key key)
        Make a singleton window visible or, if it is already visible, bring it to the front.
        Parameters:
        key - the window type
        Returns:
        the singleton window
      • showFrame

        public StatusFrame showFrame​(ApplicationWindowAction<Key> action)
        Make a non-singleton window visible or, if it is already visible, bring it to the front.
        Parameters:
        action - the action that identifies the window
        Returns:
        the window
      • createFrame

        protected StatusFrame createFrame​(ApplicationWindowAction<Key> action)
        Create and display a non-singleton window.
        Parameters:
        action - the window action specifying the type of window
        Returns:
        the new window
      • addFrame

        public java.awt.Container addFrame​(StatusFrame frame,
                                           Key windowType)
        Add an existing non-singleton window to this manager and initialize its content pane.
        Parameters:
        frame - the window
        windowType - the window type
        Returns:
        the new content pane
      • addFrame

        public void addFrame​(StatusFrame frame,
                             java.awt.Container contentPane)
      • getFrameCount

        public int getFrameCount()