Class WindowManager


  • public final class WindowManager
    extends java.lang.Object
    A JDesktop window manager.

    Major functions implemented:

    • close()
    • closeAll()
    • minimize()
    • minimizeAll()
    • maximize()
    • maximizeAll()
    • restore()
    • restoreAll()
    • hide()
    • hideAll()
    • selectNext()
    • selectPrevious()
    • reset()
    • resetAll()
    • tileHorizontally()
    • tileVertically()
    • tile()
    • cascade()

    Since:
    1.04
    Author:
    Gregory Kotsaftis
    • Constructor Summary

      Constructors 
      Constructor Description
      WindowManager​(javax.swing.JDesktopPane d, javax.swing.JMenu windowsMenu)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cascade()
      Cascades all frames.
      void close()
      Closes the selected frame if it is closable.
      void closeAll()
      Closes all frames that are closable.
      int countFrames()
      Counts all frames, even those that are closed with DefaultCloseOperation = HIDE_ON_CLOSE
      int countVisibleFrames()
      Counts only visible frames.
      boolean getAutoPositionPolicy()
      Gets the auto position frames policy.
      boolean getClosePolicy()
      Gets the close policy.
      boolean getDeiconifiablePolicy()
      Gets the de-iconifiable policy.
      boolean getOutlineDragMode()
      Gets frames' drawing strategy.
      void hide()
      Hides a frame.
      void hideAll()
      Hides all frames.
      void maximize()
      Maximizes the selected frame if it is not already maximized.
      void maximizeAll()
      Maximizes all frames that are not already maximized.
      void minimize()
      Minimizes the selected frame if it is iconifiable.
      void minimizeAll()
      Minimizes all frames that are iconifiable.
      void reset()
      Resets the frame to it's original preferred size of its components.
      void resetAll()
      Resets all frames to their original preferred size of their components.
      void restore()
      Restores the selected frame from it's maximized state.
      void restoreAll()
      Restores all frames from their maximized state.
      void selectNext()
      Selects the next internal frame.
      void selectPrevious()
      Selects the previous internal frame.
      void setAutoPositionPolicy​(boolean p)
      Sets the auto position frames policy.
      void setClosePolicy​(boolean p)
      Sets the close policy.
      void setDeiconifiablePolicy​(boolean p)
      Sets de-iconifiable policy.
      void setOutlineDragMode​(boolean outline)
      Selects frames' drawing strategy.
      void tile()
      Tiles all windows equally.
      void tileHorizontally()
      Tiles all windows horizontally.
      void tileVertically()
      Tiles all windows vertically.
      • Methods inherited from class java.lang.Object

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

      • WindowManager

        public WindowManager​(javax.swing.JDesktopPane d,
                             javax.swing.JMenu windowsMenu)
        Constructor. Creates a new WindowManager and attaches it to a desktop pane.

        Parameters:
        d - The JDesktopPane instance.
        windowsMenu - The JMenu instance.
    • Method Detail

      • setOutlineDragMode

        public void setOutlineDragMode​(boolean outline)
        Selects frames' drawing strategy.

        Parameters:
        outline - true to enable JDesktopPane.OUTLINE_DRAG_MODE, or false to enable JDesktopPane.LIVE_DRAG_MODE.
      • getOutlineDragMode

        public boolean getOutlineDragMode()
        Gets frames' drawing strategy.

        Returns:
        true if desktop's DragMode is JDesktopPane.OUTLINE_DRAG_MODE or false if desktop's DragMode is JDesktopPane.LIVE_DRAG_MODE.
      • setDeiconifiablePolicy

        public void setDeiconifiablePolicy​(boolean p)
        Sets de-iconifiable policy. Should we force a frame to de-iconify if it is iconified, during cascade operations?

        Parameters:
        p - true if force, false otherwise.
      • getDeiconifiablePolicy

        public boolean getDeiconifiablePolicy()
        Gets the de-iconifiable policy.

        Returns:
        The de-iconifiable policy.
      • setClosePolicy

        public void setClosePolicy​(boolean p)
        Sets the close policy. Should we do default close operation per frame or force close it?

        Parameters:
        p - true to force close, false do default close operation.
      • getClosePolicy

        public boolean getClosePolicy()
        Gets the close policy.

        Returns:
        true for force close, false for default close operation.
      • setAutoPositionPolicy

        public void setAutoPositionPolicy​(boolean p)
        Sets the auto position frames policy. Should we auto position the new frames in the desktop or not?

        Parameters:
        p - true for auto-position, false for none.
      • getAutoPositionPolicy

        public boolean getAutoPositionPolicy()
        Gets the auto position frames policy.

        Returns:
        The auto-position policy.
      • countFrames

        public int countFrames()
        Counts all frames, even those that are closed with DefaultCloseOperation = HIDE_ON_CLOSE

        NOTEUse this method in order to understand how many "ghost" frames remain within the desktop.

        Returns:
        The number of frames.
      • countVisibleFrames

        public int countVisibleFrames()
        Counts only visible frames.

        Returns:
        The number of visible frames.
      • close

        public void close()
        Closes the selected frame if it is closable.
      • closeAll

        public void closeAll()
        Closes all frames that are closable.
      • minimize

        public void minimize()
        Minimizes the selected frame if it is iconifiable.
      • minimizeAll

        public void minimizeAll()
        Minimizes all frames that are iconifiable.
      • restore

        public void restore()
        Restores the selected frame from it's maximized state.
      • restoreAll

        public void restoreAll()
        Restores all frames from their maximized state.
      • maximize

        public void maximize()
        Maximizes the selected frame if it is not already maximized.
      • maximizeAll

        public void maximizeAll()
        Maximizes all frames that are not already maximized.
      • reset

        public void reset()
        Resets the frame to it's original preferred size of its components.
      • resetAll

        public void resetAll()
        Resets all frames to their original preferred size of their components.
      • hide

        public void hide()
        Hides a frame. The hidden frame is added to the menu with disabled-like color.
      • hideAll

        public void hideAll()
        Hides all frames. The hidden frames are added to the menu with disabled-like color.
      • selectNext

        public void selectNext()
        Selects the next internal frame.
      • selectPrevious

        public void selectPrevious()
        Selects the previous internal frame.
      • cascade

        public void cascade()
        Cascades all frames. If De-iconifiablePolicy is false, minimized frames stay minimized.During cascade, it also sorts frames based on their title.
      • tileVertically

        public void tileVertically()
        Tiles all windows vertically.
      • tileHorizontally

        public void tileHorizontally()
        Tiles all windows horizontally.
      • tile

        public void tile()
        Tiles all windows equally.