de.caff.gimmicks.swing

## Class CollapsibleTabbedPane

- java.lang.Object
- - java.awt.Component
  - - java.awt.Container
    - - javax.swing.JComponent
      - - javax.swing.JTabbedPane
        - - de.caff.gimmicks.swing.CollapsibleTabbedPane

- All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible, javax.swing.SwingConstants

      public class CollapsibleTabbedPane
      extends javax.swing.JTabbedPane

  Collapsible tabbed pane.

  Although extending JTabbedPane, not all methods are useful.

  Basically just create this, put it to `its natural border` of a container with `BorderLayout`, and add some tabs.

  If you want to store the expanded sizes to the preferences, you should use one of the constructors with an id, as that will be used to discern between different instances of this class used in the same GUI.

  Since:
    April.28, 2016
  Author:
    Rammi
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `CollapsibleTabbedPane.ExpandableDirection` Direction in which a `CollapsiblePane` is expandable.
    `static class` | `CollapsibleTabbedPane.Side` The side where the expandable pane is placed.

    - ### Nested classes/interfaces inherited from class javax.swing.JTabbedPane

      `javax.swing.JTabbedPane.AccessibleJTabbedPane, javax.swing.JTabbedPane.ModelListener`

    - ### Nested classes/interfaces inherited from class javax.swing.JComponent

      `javax.swing.JComponent.AccessibleJComponent`

    - ### Nested classes/interfaces inherited from class java.awt.Container

      `java.awt.Container.AccessibleAWTContainer`

    - ### Nested classes/interfaces inherited from class java.awt.Component

      `java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) java.lang.String` | `id` ID used for preferences.
    `(package private) CollapsibleTabbedPane.Side` | `side`

    - ### Fields inherited from class javax.swing.JTabbedPane

      `changeEvent, changeListener, model, SCROLL_TAB_LAYOUT, tabPlacement, WRAP_TAB_LAYOUT`

    - ### Fields inherited from class javax.swing.JComponent

      `listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

    - ### Fields inherited from class java.awt.Component

      `accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

    - ### Fields inherited from interface javax.swing.SwingConstants

      `BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST`

    - ### Fields inherited from interface java.awt.image.ImageObserver

      `ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CollapsibleTabbedPane(CollapsibleTabbedPane.Side side)` Create a collapsible tabbed pane.
    `CollapsibleTabbedPane(CollapsibleTabbedPane.Side side, int tabLayoutPolicy)` Constructor.
    `CollapsibleTabbedPane(java.lang.String id, CollapsibleTabbedPane.Side side)` Constructor.
    `CollapsibleTabbedPane(java.lang.String id, CollapsibleTabbedPane.Side side, int tabLayoutPolicy)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addTabFromResource(java.lang.String baseTag, javax.swing.JComponent comp)` Add a tab from an i18n resource tag.
    `java.lang.String` | `getId()` Get the id of this pane.
    `CollapsibleTabbedPane.Side` | `getSide()` Get the side for which this pane is configured.
    `int` | `indexOfComponent(java.awt.Component component)`
    `void` | `insertTab(java.lang.String title, javax.swing.Icon icon, java.awt.Component component, java.lang.String tip, int index)` Inserts a new tab for the given component, at the given index, represented by the given title and/or icon, either of which may be `null`.
    `void` | `insertTab(java.lang.String id, java.lang.String title, javax.swing.Icon icon, java.awt.Component component, java.lang.String tip, int index)` Inserts a new tab for the given component, at the given index, represented by the given title and/or icon, either of which may be `null`.
    `void` | `insertTabFromResource(java.lang.String baseTag, javax.swing.JComponent comp, int index)` Insert a tab from an i18n resource tag.
    `void` | `loadPreferences(java.util.prefs.Preferences preferences)` Load the expanded sizes of the tabs from the given preference.
    `void` | `setSelectedIndex(int index)`
    `void` | `storePreferences(java.util.prefs.Preferences preferences)` Store the expanded sizes of the tabs to the given preferences.

    - ### Methods inherited from class javax.swing.JTabbedPane

      `add, add, add, add, add, addChangeListener, addTab, addTab, addTab, createChangeListener, fireStateChanged, getAccessibleContext, getBackgroundAt, getBoundsAt, getChangeListeners, getComponentAt, getDisabledIconAt, getDisplayedMnemonicIndexAt, getForegroundAt, getIconAt, getMnemonicAt, getModel, getSelectedComponent, getSelectedIndex, getTabComponentAt, getTabCount, getTabLayoutPolicy, getTabPlacement, getTabRunCount, getTitleAt, getToolTipText, getToolTipTextAt, getUI, getUIClassID, indexAtLocation, indexOfTab, indexOfTab, indexOfTabComponent, isEnabledAt, paramString, remove, remove, removeAll, removeChangeListener, removeTabAt, setBackgroundAt, setComponentAt, setDisabledIconAt, setDisplayedMnemonicIndexAt, setEnabledAt, setForegroundAt, setIconAt, setMnemonicAt, setModel, setSelectedComponent, setTabComponentAt, setTabLayoutPolicy, setTabPlacement, setTitleAt, setToolTipTextAt, setUI, updateUI`

    - ### Methods inherited from class javax.swing.JComponent

      `addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

    - ### Methods inherited from class java.awt.Container

      `addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree`

    - ### Methods inherited from class java.awt.Component

      `action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

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

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

- - ### Field Detail

    - #### side

          @NotNull
          final CollapsibleTabbedPane.Side side

    - #### id

          @NotNull
          final java.lang.String id

      ID used for preferences.

  - ### Constructor Detail

    - #### CollapsibleTabbedPane

          public CollapsibleTabbedPane(@NotNull
                                       CollapsibleTabbedPane.Side side)

      Create a collapsible tabbed pane. This uses `wrapped tab layout` and a generic id which is shared with all instances of this class..
      Parameters:
        `side` - side to which this pane is added

    - #### CollapsibleTabbedPane

          public CollapsibleTabbedPane(@NotNull
                                       CollapsibleTabbedPane.Side side,
                                       int tabLayoutPolicy)

      Constructor. This uses a generic id ahared wiht all instances of this class.
      Parameters:
        `side` - side to which this pane is added
        `tabLayoutPolicy` - tab layout policy

    - #### CollapsibleTabbedPane

          public CollapsibleTabbedPane(@NotNull
                                       java.lang.String id,
                                       @NotNull
                                       CollapsibleTabbedPane.Side side)

      Constructor. This uses `wrapped tab layout`.
      Parameters:
        `id` - unique id used for storing and recovering preferences
        `side` - side to which this pane is added

    - #### CollapsibleTabbedPane

          public CollapsibleTabbedPane(@NotNull
                                       java.lang.String id,
                                       @NotNull
                                       CollapsibleTabbedPane.Side side,
                                       int tabLayoutPolicy)

      Constructor.
      Parameters:
        `id` - unique id used for storing and recovering preferences
        `side` - side to which this pane is added
        `tabLayoutPolicy` - tab layout policy, see extended class

  - ### Method Detail

    - #### getSide

          @NotNull
          public CollapsibleTabbedPane.Side getSide()

      Get the side for which this pane is configured.
      Returns:
        side to which this pane should be attached

    - #### getId

          @NotNull
          public java.lang.String getId()

      Get the id of this pane.
      Returns:
        id

    - #### addTabFromResource

          public void addTabFromResource(@NotNull
                                         java.lang.String baseTag,
                                         @NotNull
                                         javax.swing.JComponent comp)

      Add a tab from an i18n resource tag.
      Parameters:
        `baseTag` - base tag of i18n resource
        `comp` - component to insert

    - #### insertTabFromResource

          public void insertTabFromResource(@NotNull
                                            java.lang.String baseTag,
                                            @NotNull
                                            javax.swing.JComponent comp,
                                            int index)

      Insert a tab from an i18n resource tag.
      Parameters:
        `baseTag` - base tag of i18n resource
        `comp` - component to insert
        `index` - index where to insert

    - #### insertTab

          public void insertTab(java.lang.String title,
                                javax.swing.Icon icon,
                                java.awt.Component component,
                                java.lang.String tip,
                                int index)

      Inserts a new tab for the given component, at the given index, represented by the given title and/or icon, either of which may be `null`.
      Overrides:
        `insertTab` in class `javax.swing.JTabbedPane`
      Parameters:
        `title` - the title to be displayed on the tab
        `icon` - the icon to be displayed on the tab
        `component` - the component to be displayed when this tab is clicked.
        `tip` - the tooltip to be displayed for this tab
        `index` - the position to insert this new tab (`&gt; 0 and &lt;= getTabCount()`)
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the index is out of range (`&lt; 0 or &gt; getTabCount()`)
      See Also:
        `JTabbedPane.addTab(java.lang.String, javax.swing.Icon, java.awt.Component, java.lang.String)`, `JTabbedPane.removeTabAt(int)`

    - #### insertTab

          public void insertTab(@NotNull
                                java.lang.String id,
                                @Nullable
                                java.lang.String title,
                                @Nullable
                                javax.swing.Icon icon,
                                @NotNull
                                java.awt.Component component,
                                @Nullable
                                java.lang.String tip,
                                int index)

      Inserts a new tab for the given component, at the given index, represented by the given title and/or icon, either of which may be `null`.
      Parameters:
        `id` - tab ID
        `title` - the title to be displayed on the tab
        `icon` - the icon to be displayed on the tab
        `component` - the component to be displayed when this tab is clicked.
        `tip` - the tooltip to be displayed for this tab
        `index` - the position to insert this new tab (`&gt; 0 and &lt;= getTabCount()`)
      Throws:
        `java.lang.IndexOutOfBoundsException` - if the index is out of range (`&lt; 0 or &gt; getTabCount()`)
      See Also:
        `JTabbedPane.addTab(java.lang.String, javax.swing.Icon, java.awt.Component, java.lang.String)`, `JTabbedPane.removeTabAt(int)`

    - #### loadPreferences

          public void loadPreferences(@NotNull
                                      java.util.prefs.Preferences preferences)

      Load the expanded sizes of the tabs from the given preference.
      Parameters:
        `preferences` - preferences

    - #### storePreferences

          public void storePreferences(@NotNull
                                       java.util.prefs.Preferences preferences)

      Store the expanded sizes of the tabs to the given preferences.
      Parameters:
        `preferences` - preferences

    - #### indexOfComponent

          public int indexOfComponent(java.awt.Component component)

      Overrides:
        `indexOfComponent` in class `javax.swing.JTabbedPane`

    - #### setSelectedIndex

          public void setSelectedIndex(int index)

      Overrides:
        `setSelectedIndex` in class `javax.swing.JTabbedPane`