Class BaseTabbedPane

    • Field Detail

      • m_CloseTabsWithMiddleMouseButton

        protected boolean m_CloseTabsWithMiddleMouseButton
        Allows the user to close tabs with the middle mouse button.
      • m_ShowCloseTabButton

        protected boolean m_ShowCloseTabButton
        whether to show a "close tab" button.
      • m_PromptUserWhenClosingTab

        protected boolean m_PromptUserWhenClosingTab
        whether to prompt user when closing a tab.
      • m_DetachableTabs

        protected boolean m_DetachableTabs
        whether to make tabs detachable.
      • m_MaxTitleLength

        protected int m_MaxTitleLength
        the maximum length in chars for titles before getting shortened.
      • m_MaxTabCloseUndo

        protected int m_MaxTabCloseUndo
        the maximum number of tabs to keep for undo.
      • m_SkipTabUndo

        protected boolean m_SkipTabUndo
        whether to skip tab undo.
      • m_TabChangeListeners

        protected Set<ChangeListener> m_TabChangeListeners
        the listeners for tab changes.
      • m_TabClosedListeners

        protected Set<TabClosedListener> m_TabClosedListeners
        the listeners for tabs being closed.
    • Constructor Detail

      • BaseTabbedPane

        public BaseTabbedPane()
        Creates an empty TabbedPane with a default tab placement of JTabbedPane.TOP.
      • BaseTabbedPane

        public BaseTabbedPane​(int tabPlacement)
        Creates an empty TabbedPane with the specified tab placement of either: JTabbedPane.TOP, JTabbedPane.BOTTOM, JTabbedPane.LEFT, or JTabbedPane.RIGHT.
        Parameters:
        tabPlacement - the placement for the tabs relative to the content
      • BaseTabbedPane

        public BaseTabbedPane​(int tabPlacement,
                              int tabLayoutPolicy)
        Creates an empty TabbedPane with the specified tab placement and tab layout policy. Tab placement may be either: JTabbedPane.TOP, JTabbedPane.BOTTOM, JTabbedPane.LEFT, or JTabbedPane.RIGHT. Tab layout policy may be either: JTabbedPane.WRAP_TAB_LAYOUT or JTabbedPane.SCROLL_TAB_LAYOUT.
        Parameters:
        tabPlacement - the placement for the tabs relative to the content
        tabLayoutPolicy - the policy for laying out tabs when all tabs will not fit on one run
    • Method Detail

      • initialize

        protected void initialize()
        Performs further initializations of widgets.
      • initGUI

        protected void initGUI()
        Performs further initializations of widgets.
      • finishInit

        protected void finishInit()
        Finishes the initialization.
      • canCloseTab

        public boolean canCloseTab​(int index)
        Prompts the user whether the tab can be closed.
        Parameters:
        index - the index of the tab to be closed
        Returns:
        true if can be closed
      • canCloseTabWithMiddleMouseButton

        protected boolean canCloseTabWithMiddleMouseButton​(int index)
        Hook method that checks whether the specified tab can really be closed with a click of the middle mouse button.

        Default implementation always returns true.
        Parameters:
        index - the tab index
        Returns:
        true if tab can be closed
        See Also:
        getCloseTabsWithMiddelMouseButton()
      • afterTabClosedWithMiddleMouseButton

        protected void afterTabClosedWithMiddleMouseButton​(int index,
                                                           Component comp)
        Hook method that gets executed after a tab was successfully removed with a middle mouse button click.

        Default implementation calls cleanUp() method of CleanUpHandler instances.
        Parameters:
        index - the original index
        comp - the component that was removed
      • setCloseTabsWithMiddleMouseButton

        public void setCloseTabsWithMiddleMouseButton​(boolean value)
        Sets whether users can close tabs with the middle mouse button.
        Parameters:
        value - if true then users can close tabs with the middle mouse button
        See Also:
        canCloseTabWithMiddleMouseButton(int)
      • getCloseTabsWithMiddelMouseButton

        public boolean getCloseTabsWithMiddelMouseButton()
        Returns whether users can close tabs with the middle mouse button.
        Returns:
        true if users can close tabs with the middle mouse button
        See Also:
        canCloseTabWithMiddleMouseButton(int)
      • setShowCloseTabButton

        public void setShowCloseTabButton​(boolean value)
        Sets whether to show "close tab" buttons.
        Parameters:
        value - true if to show buttons
      • getShowCloseTabButton

        public boolean getShowCloseTabButton()
        Returns whether to show "close tab" buttons.
        Returns:
        true if button displayed
      • setDetachableTabs

        public void setDetachableTabs​(boolean value)
        Sets whether to allow tabs to be detached.
        Parameters:
        value - true if detachable
      • getDetachableTabs

        public boolean getDetachableTabs()
        Returns whether to allow tabs to be detached.
        Returns:
        true if detachable
      • updateTabComponents

        protected void updateTabComponents()
        Updates the tab components.
      • setPromptUserWhenClosingTab

        public void setPromptUserWhenClosingTab​(boolean value)
        Sets whether to prompt the user when closing a tab.
        Parameters:
        value - true if to prompt
      • getPromptUserWhenClosingTab

        public boolean getPromptUserWhenClosingTab()
        Returns whether to prompt the user when closing a tab.
        Returns:
        true if to prompt
      • removeSelectedTab

        public boolean removeSelectedTab()
        Removes the currently selected tab.
        Returns:
        true if a tab was removed
      • insertTab

        public void insertTab​(String title,
                              Icon icon,
                              Component component,
                              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 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 (> 0 and <= getTabCount())
        Throws:
        IndexOutOfBoundsException - if the index is out of range (< 0 or > getTabCount())
      • setTitleAt

        public void setTitleAt​(int index,
                               String title)
        Sets the title for the tab at the specified position.
        Overrides:
        setTitleAt in class JTabbedPane
        Parameters:
        index - the position of the tab
        title - the new title
      • setShortenedTitleAt

        public void setShortenedTitleAt​(int index,
                                        String title)
        Sets the title for the tab at the specified position.
        Parameters:
        index - the position of the tab
        title - the new title
      • setMaxTitleLength

        public void setMaxTitleLength​(int value)
        Sets the maximum title length to allow before shortening when using setShortenedTitleAt(int, String).
        Parameters:
        value - the maximum length in chars
      • getMaxTitleLength

        public int getMaxTitleLength()
        Returns the maximum title length to allow before shortening when using setShortenedTitleAt(int, String).
        Returns:
        the maximum length in chars
      • setMaxTabCloseUndo

        public void setMaxTabCloseUndo​(int value)
        Sets the maximum tabs to keep around for undoing closing.
        Parameters:
        value - the maximum, <1 turned off
      • getMaxTabCloseUndo

        public int getMaxTabCloseUndo()
        Returns the maximum tabs to keep around for undoing closing.
        Returns:
        the maximum, <1 turned off
      • generateTabUndo

        protected BaseTabbedPane.TabUndo generateTabUndo​(int index)
        Generates a tab undo container.
        Parameters:
        index - the index of the tab to back up
        Returns:
        the undo container
      • addTabUndo

        protected void addTabUndo​(int index)
        Adds the tab to its undo list, if enabled.
        Parameters:
        index - the position of the tab
      • canUndoTabClose

        public boolean canUndoTabClose()
        Returns whether a tab close can be undone.
        Returns:
        true if possible
      • undoTabClose

        public boolean undoTabClose()
        Performs an undo of a tab close.
        Returns:
        true if successfully restored
      • removeTabAt

        public void removeTabAt​(int index)
        Removes the tab at index. Automatically handles the tab undo.
        Overrides:
        removeTabAt in class JTabbedPane
        Parameters:
        index - the index of the tab to be removed
        Throws:
        IndexOutOfBoundsException - if index is out of range (index < 0 || index >= tab count)
      • removeAll

        public void removeAll()
        Removes all the tabs and their corresponding components from the tabbedpane. Bypasses undo for tabs, clears the undo list.
        Overrides:
        removeAll in class JTabbedPane
      • canMoveTabTo

        protected boolean canMoveTabTo​(int from,
                                       int to)
        Returns whether the tab can be moved.
        Parameters:
        from - the current tab's index
        to - the destination index
        Returns:
        true if can be moved
      • canMoveTabToStart

        public boolean canMoveTabToStart​(int from)
        Returns whether the tab can be moved to the start.
        Parameters:
        from - the current tab's index
        Returns:
        true if can be moved
      • canMoveTabToLeft

        public boolean canMoveTabToLeft​(int from)
        Returns whether the tab can be moved to the left.
        Parameters:
        from - the current tab's index
        Returns:
        true if can be moved
      • canMoveTabToRight

        public boolean canMoveTabToRight​(int from)
        Returns whether the tab can be moved to the right.
        Parameters:
        from - the current tab's index
        Returns:
        true if can be moved
      • canMoveTabToEnd

        public boolean canMoveTabToEnd​(int from)
        Returns whether the tab can be moved to the end.
        Parameters:
        from - the current tab's index
        Returns:
        true if can be moved
      • moveTabTo

        protected void moveTabTo​(int from,
                                 int to)
        Moves a tab from A to B.
        Parameters:
        from - the current position
        to - the new position
      • moveTabToStart

        public boolean moveTabToStart​(int index)
        Moves the tab to the left most position.
        Parameters:
        index - the tab's current index
        Returns:
        true if successfully moved
      • moveTabToLeft

        public boolean moveTabToLeft​(int index)
        Moves the tab to the left.
        Parameters:
        index - the tab's current index
        Returns:
        true if successfully moved
      • moveTabToRight

        public boolean moveTabToRight​(int index)
        Moves the tab to the right.
        Parameters:
        index - the tab's current index
        Returns:
        true if successfully moved
      • moveTabToEnd

        public boolean moveTabToEnd​(int index)
        Moves the tab to the right most position.
        Parameters:
        index - the tab's current index
        Returns:
        true if successfully moved
      • getTabMoveSubMenu

        public BaseMenu getTabMoveSubMenu​(int index)
        Generates the submenu for moving tabs.
        Parameters:
        index - the current tab's index
        Returns:
        the submenu
      • addTabChangeListener

        public void addTabChangeListener​(ChangeListener l)
        Adds the listener for changes in tabs.
        Parameters:
        l - the listener to add
      • removeTabChangeListener

        public void removeTabChangeListener​(ChangeListener l)
        Removes the listener for changes in tabs.
        Parameters:
        l - the listener to remove
      • clearTabChangeListeners

        public void clearTabChangeListeners()
        Removes all tab change listeners.
      • notifyTabChangeListeners

        protected void notifyTabChangeListeners()
        Notifies all the tab change listeners
      • addTabClosedListeners

        public void addTabClosedListeners​(TabClosedListener l)
        Adds the listener for closing tabs.
        Parameters:
        l - the listener to add
      • removeTabClosedListeners

        public void removeTabClosedListeners​(TabClosedListener l)
        Removes the listener for closing tabs.
        Parameters:
        l - the listener to remove
      • clearTabClosedListeners

        public void clearTabClosedListeners()
        Removes all tab closed listeners.
      • notifyTabClosedListeners

        protected void notifyTabClosedListeners​(int tabIndex,
                                                Component component)
        Notifies all the tab closed listeners
        Parameters:
        tabIndex - the index of the tab that got closed
        component - the component that got removed