Class FlatTabbedPane

    • Constructor Detail

      • FlatTabbedPane

        public FlatTabbedPane()
    • Method Detail

      • isShowTabSeparators

        public boolean isShowTabSeparators()
        Returns whether separators are shown between tabs.
      • setShowTabSeparators

        public void setShowTabSeparators​(boolean showTabSeparators)
        Specifies whether separators are shown between tabs.
      • isShowContentSeparators

        public boolean isShowContentSeparators()
        Returns whether the separator between tabs area and content area should be shown.
      • setShowContentSeparators

        public void setShowContentSeparators​(boolean showContentSeparators)
        Specifies whether the separator between tabs area and content area should be shown.
      • isHasFullBorder

        public boolean isHasFullBorder()
        Returns whether a full border is painted around a tabbed pane.
      • setHasFullBorder

        public void setHasFullBorder​(boolean hasFullBorder)
        Specifies whether a full border is painted around a tabbed pane.
      • isHideTabAreaWithOneTab

        public boolean isHideTabAreaWithOneTab()
        Returns whether the tab area should be hidden if it contains only one tab.
      • setHideTabAreaWithOneTab

        public void setHideTabAreaWithOneTab​(boolean hideTabAreaWithOneTab)
        Specifies whether the tab area should be hidden if it contains only one tab.
      • getMinimumTabWidth

        public int getMinimumTabWidth()
        Returns the minimum width of a tab.
      • setMinimumTabWidth

        public void setMinimumTabWidth​(int minimumTabWidth)
        Specifies the minimum width of a tab.
      • getMinimumTabWidth

        public int getMinimumTabWidth​(int tabIndex)
        Returns the minimum width of the tab at the given tab index.
      • setMinimumTabWidth

        public void setMinimumTabWidth​(int tabIndex,
                                       int minimumTabWidth)
        Specifies the minimum width of the tab at the given tab index.
      • getMaximumTabWidth

        public int getMaximumTabWidth()
        Returns the maximum width of a tab.
      • getMaximumTabWidth

        public int getMaximumTabWidth​(int tabIndex)
        Returns the maximum width of the tab at the given tab index.
      • setMaximumTabWidth

        public void setMaximumTabWidth​(int tabIndex,
                                       int maximumTabWidth)
        Specifies the maximum width of the tab at the given tab index.

        Applied only if tab does not have a custom tab component (see JTabbedPane.setTabComponentAt(int, java.awt.Component)).

      • getTabHeight

        public int getTabHeight()
        Returns the minimum height of a tab.
      • setTabHeight

        public void setTabHeight​(int tabHeight)
        Specifies the minimum height of a tab.
        See Also:
        setTabInsets(Insets)
      • getTabInsets

        public Insets getTabInsets()
        Returns the insets of a tab.
      • setTabInsets

        public void setTabInsets​(Insets tabInsets)
        Specifies the insets of a tab.
        See Also:
        setTabHeight(int)
      • getTabInsets

        public Insets getTabInsets​(int tabIndex)
        Returns the insets of the tab at the given tab index.
      • setTabInsets

        public void setTabInsets​(int tabIndex,
                                 Insets tabInsets)
        Specifies the insets of the tab at the given tab index.
        See Also:
        setTabHeight(int)
      • getTabAreaInsets

        public Insets getTabAreaInsets()
        Returns the insets of the tab area.
      • setTabAreaInsets

        public void setTabAreaInsets​(Insets tabAreaInsets)
        Specifies the insets of the tab area.
      • isTabsClosable

        public boolean isTabsClosable()
        Returns whether all tabs are closable.
      • setTabsClosable

        public void setTabsClosable​(boolean tabClosable)
        Specifies whether all tabs are closable. If set to true, all tabs in that tabbed pane are closable. To make individual tabs closable, use setTabClosable(int, boolean).

        Note that you have to specify a callback (see setTabCloseCallback(BiConsumer)) that is invoked when the user clicks a tab close button. The callback is responsible for closing the tab.

      • isTabClosable

        public Boolean isTabClosable​(int tabIndex)
        Returns whether the tab at the given tab index is closable.
      • setTabClosable

        public void setTabClosable​(int tabIndex,
                                   boolean tabClosable)
        Specifies whether the tab at the given tab index is closable. To make all tabs closable, use setTabsClosable(boolean).

        Note that you have to specify a callback (see setTabCloseCallback(BiConsumer)) that is invoked when the user clicks a tab close button. The callback is responsible for closing the tab.

      • getTabCloseToolTipText

        public String getTabCloseToolTipText()
        Returns the tooltip text used for tab close buttons.
      • setTabCloseToolTipText

        public void setTabCloseToolTipText​(String tabCloseToolTipText)
        Specifies the tooltip text used for tab close buttons.
      • getTabCloseToolTipText

        public String getTabCloseToolTipText​(int tabIndex)
        Returns the tooltip text used for tab close button at the given tab index.
      • setTabCloseToolTipText

        public void setTabCloseToolTipText​(int tabIndex,
                                           String tabCloseToolTipText)
        Specifies the tooltip text used for tab close button at the given tab index.
      • getTabCloseCallback

        public BiConsumer<JTabbedPane,​Integer> getTabCloseCallback()
        Returns the callback that is invoked when a tab close button is clicked. The callback is responsible for closing the tab.
      • setTabCloseCallback

        public void setTabCloseCallback​(BiConsumer<JTabbedPane,​Integer> tabCloseCallback)
        Specifies the callback that is invoked when a tab close button is clicked. The callback is responsible for closing the tab.

        Use a BiConsumer<javax.swing.JTabbedPane, Integer> that receives the tabbed pane and the tab index as parameters:

        
         myTabbedPane.setTabCloseCallback( (tabbedPane, tabIndex) -> {
             // close tab here
         } );
         
        If you need to check whether a modifier key (e.g. Alt or Shift) was pressed while the user clicked the tab close button, use EventQueue.getCurrentEvent() to get current event, check whether it is a MouseEvent and invoke its methods. E.g.
        
         AWTEvent e = EventQueue.getCurrentEvent();
         boolean shift = (e instanceof MouseEvent) ? ((MouseEvent)e).isShiftDown() : false;
         
      • getTabCloseCallback

        public BiConsumer<JTabbedPane,​Integer> getTabCloseCallback​(int tabIndex)
        Returns the callback that is invoked when the tab close button at the given tab index is clicked. The callback is responsible for closing the tab.
      • setTabCloseCallback

        public void setTabCloseCallback​(int tabIndex,
                                        BiConsumer<JTabbedPane,​Integer> tabCloseCallback)
        Specifies the callback that is invoked when the tab close button at the given tab index is clicked. The callback is responsible for closing the tab.
        See Also:
        setTabCloseCallback(BiConsumer)
      • setTabType

        public void setTabType​(FlatTabbedPane.TabType tabType)
        Specifies type of selected tab.
        Since:
        2
      • getTabsPopupPolicy

        public FlatTabbedPane.TabsPopupPolicy getTabsPopupPolicy()
        Returns the display policy for the "more tabs" button, which shows a popup menu with the (partly) hidden tabs.
      • setTabsPopupPolicy

        public void setTabsPopupPolicy​(FlatTabbedPane.TabsPopupPolicy tabsPopupPolicy)
        Specifies the display policy for the "more tabs" button, which shows a popup menu with the (partly) hidden tabs.
      • setScrollButtonsPolicy

        public void setScrollButtonsPolicy​(FlatTabbedPane.ScrollButtonsPolicy scrollButtonsPolicy)
        Specifies the display policy for the forward/backward scroll arrow buttons.
      • setScrollButtonsPlacement

        public void setScrollButtonsPlacement​(FlatTabbedPane.ScrollButtonsPlacement scrollButtonsPlacement)
        Specifies the placement of the forward/backward scroll arrow buttons.
      • setTabAlignment

        public void setTabAlignment​(FlatTabbedPane.TabAlignment tabAlignment)
        Specifies the horizontal alignment of the tab title and icon.
      • setTabRotation

        public void setTabRotation​(FlatTabbedPane.TabRotation tabRotation)
        Specifies how the tabs should be rotated.
        Since:
        3.3
      • getTabIconPlacement

        public int getTabIconPlacement()
        Returns the tab icon placement (relative to tab title).
      • getLeadingComponent

        public Component getLeadingComponent()
        Returns a component that will be placed at the leading edge of the tabs area.
      • setLeadingComponent

        public void setLeadingComponent​(Component leadingComponent)
        Specifies a component that will be placed at the leading edge of the tabs area.

        For top and bottom tab placement, the layed out component size will be the preferred component width and the tab area height.
        For left and right tab placement, the layed out component size will be the tab area width and the preferred component height.

      • getTrailingComponent

        public Component getTrailingComponent()
        Returns a component that will be placed at the trailing edge of the tabs area.
      • setTrailingComponent

        public void setTrailingComponent​(Component trailingComponent)
        Specifies a component that will be placed at the trailing edge of the tabs area.

        For top and bottom tab placement, the layed out component size will be the available horizontal space (minimum is preferred component width) and the tab area height.
        For left and right tab placement, the layed out component size will be the tab area width and the available vertical space (minimum is preferred component height).