Class FlatTabbedPaneUI.FlatTabbedPaneLayout

  • All Implemented Interfaces:
    java.awt.LayoutManager
    Direct Known Subclasses:
    FlatTabbedPaneUI.FlatTabbedPaneScrollLayout
    Enclosing class:
    FlatTabbedPaneUI

    protected class FlatTabbedPaneUI.FlatTabbedPaneLayout
    extends javax.swing.plaf.basic.BasicTabbedPaneUI.TabbedPaneLayout
    Layout manager for wrap tab layout policy (and base class for scroll tab layout policy).

    Component hierarchy for wrap tab layout policy:

    
     JTabbedPane
        +- 1...n tab content components
        +- (optional) BasicTabbedPaneUI.TabContainer (extends JPanel)
        |  +- 1..n tab components (shown in tab area)
        +- (optional) ContainerUIResource (extends JPanel)
        |  +- leading component
        +- (optional) ContainerUIResource (extends JPanel)
           +- trailing component
     

    Instead of using super.layoutContainer(Container) and fixing some component bounds, this class implements layoutContainer(Container) and moves/resizes components only once. This avoids that some components are moved/resized twice, which would unnecessary repaint and relayout tabbed pane. In some special case this resulted in "endless" layouting and repainting when using nested tabbed panes (top and bottom tab placement) and RSyntaxTextArea (with enabled line-wrapping) as tab content.

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected FlatTabbedPaneLayout()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.awt.Dimension calculateSize​(boolean minimum)  
      protected java.awt.Dimension calculateTabAreaSize()
      Calculate preferred size of the tab area.
      (package private) java.awt.Rectangle getContentAreaLayoutBounds​(int tabPlacement, java.awt.Insets tabAreaInsets)
      Returns bounds for content components.
      (package private) java.awt.Rectangle getTabAreaLayoutBounds​(int tabPlacement, java.awt.Insets tabAreaInsets)
      Returns bounds for leading/trailing components and tab area.
      protected boolean isContentEmpty()
      Check whether all content components are either null or have zero preferred size.
      (package private) boolean isTabContainer​(java.awt.Component c)  
      protected void layoutChildComponent​(java.awt.Component c, java.awt.Rectangle contentAreaBounds)  
      protected void layoutChildComponents()  
      void layoutContainer​(java.awt.Container parent)  
      protected void layoutContainerImpl()  
      (package private) java.awt.Rectangle layoutLeftAndRightComponents​(java.awt.Rectangle tr, int tabAreaAlignment, java.awt.Insets tabAreaInsets, boolean useTabAreaAlignment, boolean shiftTabs, boolean leftToRight)  
      (package private) void layoutTabComponents​(java.awt.Component tabContainer)
      Layouts custom components in tabs.
      private void layoutTabContainer​(java.awt.Component tabContainer)
      Layouts container used for custom components in tabs.
      (package private) java.awt.Rectangle layoutTopAndBottomComponents​(java.awt.Rectangle tr, int tabAreaAlignment, java.awt.Insets tabAreaInsets, boolean useTabAreaAlignment, boolean shiftTabs)  
      • Methods inherited from class javax.swing.plaf.basic.BasicTabbedPaneUI.TabbedPaneLayout

        addLayoutComponent, calculateLayoutInfo, calculateTabRects, minimumLayoutSize, normalizeTabRuns, padSelectedTab, padTabRun, preferredLayoutSize, preferredTabAreaHeight, preferredTabAreaWidth, removeLayoutComponent, rotateTabRuns
      • Methods inherited from class java.lang.Object

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

      • FlatTabbedPaneLayout

        protected FlatTabbedPaneLayout()
    • Method Detail

      • calculateSize

        protected java.awt.Dimension calculateSize​(boolean minimum)
        Overrides:
        calculateSize in class javax.swing.plaf.basic.BasicTabbedPaneUI.TabbedPaneLayout
      • isContentEmpty

        protected boolean isContentEmpty()
        Check whether all content components are either null or have zero preferred size.

        If true, assume that the tabbed pane is used without any content and use the size of the tab area (single run) as minimum/preferred size.

      • calculateTabAreaSize

        protected java.awt.Dimension calculateTabAreaSize()
        Calculate preferred size of the tab area. Used only if isContentEmpty() returns true.
      • layoutContainer

        public void layoutContainer​(java.awt.Container parent)
        Specified by:
        layoutContainer in interface java.awt.LayoutManager
        Overrides:
        layoutContainer in class javax.swing.plaf.basic.BasicTabbedPaneUI.TabbedPaneLayout
      • layoutContainerImpl

        protected void layoutContainerImpl()
        Since:
        3.3
      • layoutChildComponents

        protected void layoutChildComponents()
        Since:
        3.3
      • layoutChildComponent

        protected void layoutChildComponent​(java.awt.Component c,
                                            java.awt.Rectangle contentAreaBounds)
        Since:
        3.3
      • isTabContainer

        boolean isTabContainer​(java.awt.Component c)
      • layoutTabContainer

        private void layoutTabContainer​(java.awt.Component tabContainer)
        Layouts container used for custom components in tabs.
      • layoutTabComponents

        void layoutTabComponents​(java.awt.Component tabContainer)
        Layouts custom components in tabs.
      • getContentAreaLayoutBounds

        java.awt.Rectangle getContentAreaLayoutBounds​(int tabPlacement,
                                                      java.awt.Insets tabAreaInsets)
        Returns bounds for content components.
      • getTabAreaLayoutBounds

        java.awt.Rectangle getTabAreaLayoutBounds​(int tabPlacement,
                                                  java.awt.Insets tabAreaInsets)
        Returns bounds for leading/trailing components and tab area. Note: Returns bounds for first tabs row only. For multi-rows tabs in wrap mode, the returned bounds does not include full tab area.
      • layoutLeftAndRightComponents

        java.awt.Rectangle layoutLeftAndRightComponents​(java.awt.Rectangle tr,
                                                        int tabAreaAlignment,
                                                        java.awt.Insets tabAreaInsets,
                                                        boolean useTabAreaAlignment,
                                                        boolean shiftTabs,
                                                        boolean leftToRight)
      • layoutTopAndBottomComponents

        java.awt.Rectangle layoutTopAndBottomComponents​(java.awt.Rectangle tr,
                                                        int tabAreaAlignment,
                                                        java.awt.Insets tabAreaInsets,
                                                        boolean useTabAreaAlignment,
                                                        boolean shiftTabs)