Class PanelManager


  • public class PanelManager
    extends java.lang.Object
    Manages the adding of components to a panel, automatically tranlating between logical element placement and the panel's layout.
    Author:
    mccreedy
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.GridBagConstraints gbc
      DOCUMENT ME!
      private javax.swing.JPanel managedPanel
      DOCUMENT ME!
    • Constructor Summary

      Constructors 
      Constructor Description
      PanelManager()
      Construct the panel manager with a new panel.
      PanelManager​(java.lang.String title)
      Construct the panel manager with a new panel that has a titled border.
      PanelManager​(javax.swing.JPanel panel)
      Construct the panel manager and attach it to a panel which has already been created.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(javax.swing.JComponent component)
      Adds a new component to the panel.
      void add​(javax.swing.JComponent component, int anchorPosition)
      Adds a new component to the panel.
      void addOnNextLine​(javax.swing.JComponent component)
      Adds a new component to the panel on a new line (vertically).
      void addOnNextLine​(javax.swing.JComponent component, int anchorPosition)
      Adds a new component to the panel on a new line (vertically).
      java.awt.GridBagConstraints getConstraints()
      Returns the current constraints of this panel manager.
      javax.swing.JPanel getPanel()
      Returns the managed panel.
      private java.awt.GridBagConstraints initConstraints()
      Create a new set of grid bag constraints.
      private javax.swing.JPanel initPanel()
      Create a new panel.
      private void moveToNextLine()
      Force new components which are added to appear on the next line in the panel (vertically).
      void setPanel​(javax.swing.JPanel panel)
      Changes the panel which is managed by this class.
      • Methods inherited from class java.lang.Object

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

      • gbc

        private java.awt.GridBagConstraints gbc
        DOCUMENT ME!
      • managedPanel

        private javax.swing.JPanel managedPanel
        DOCUMENT ME!
    • Constructor Detail

      • PanelManager

        public PanelManager()
        Construct the panel manager with a new panel.
      • PanelManager

        public PanelManager​(java.lang.String title)
        Construct the panel manager with a new panel that has a titled border.
        Parameters:
        title - the title to put on the new panel's border
      • PanelManager

        public PanelManager​(javax.swing.JPanel panel)
        Construct the panel manager and attach it to a panel which has already been created.
        Parameters:
        panel - the panel to manage
    • Method Detail

      • add

        public void add​(javax.swing.JComponent component)
        Adds a new component to the panel.
        Parameters:
        component - the component to add
      • add

        public void add​(javax.swing.JComponent component,
                        int anchorPosition)
        Adds a new component to the panel.
        Parameters:
        component - the component to add
        anchorPosition - the position to anchor the component to (from GridBagConstraints)
      • addOnNextLine

        public void addOnNextLine​(javax.swing.JComponent component)
        Adds a new component to the panel on a new line (vertically).
        Parameters:
        component - the component to add
      • addOnNextLine

        public void addOnNextLine​(javax.swing.JComponent component,
                                  int anchorPosition)
        Adds a new component to the panel on a new line (vertically).
        Parameters:
        component - the component to add
        anchorPosition - the position to anchor the component to (from GridBagConstraints)
      • getConstraints

        public java.awt.GridBagConstraints getConstraints()
        Returns the current constraints of this panel manager.
        Returns:
        the current grid bag constraints
      • getPanel

        public javax.swing.JPanel getPanel()
        Returns the managed panel.
        Returns:
        the managed panel
      • setPanel

        public void setPanel​(javax.swing.JPanel panel)
        Changes the panel which is managed by this class. Forces the panel to use a grid bag layout.
        Parameters:
        panel - the panel to manage
      • initConstraints

        private java.awt.GridBagConstraints initConstraints()
        Create a new set of grid bag constraints.
        Returns:
        new layout constraints
      • initPanel

        private javax.swing.JPanel initPanel()
        Create a new panel.
        Returns:
        a new panel, with a grid bag layout
      • moveToNextLine

        private void moveToNextLine()
        Force new components which are added to appear on the next line in the panel (vertically).