Class BaseTabbedPaneUI

All Implemented Interfaces:
SwingConstants
Direct Known Subclasses:
AcrylTabbedPaneUI, AeroTabbedPaneUI, AluminiumTabbedPaneUI, BernsteinTabbedPaneUI, FastTabbedPaneUI, GraphiteTabbedPaneUI, HiFiTabbedPaneUI, LunaTabbedPaneUI, McWinTabbedPaneUI, MintTabbedPaneUI, SmartTabbedPaneUI, TextureTabbedPaneUI

public class BaseTabbedPaneUI extends TabbedPaneUI implements SwingConstants
This class is a modified copy of the javax.swing.plaf.basic.BasicTabbedPaneUI A Basic L&F implementation of TabbedPaneUI.
Version:
1.87 06/08/99 Author Amy Fowler Author Philip Milne Author Steve Wilson Author Tom Santos Author Dave Moore Author Michael Hagen
  • Field Details

    • NULL_BORDER_INSETS

      protected static final Insets NULL_BORDER_INSETS
      Constant NULL_BORDER_INSETS
    • GAP

      protected static final int GAP
      Constant GAP=5
      See Also:
    • tabPane

      protected JTabbedPane tabPane
    • tabAreaBackground

      protected Color tabAreaBackground
    • selectedColor

      protected Color selectedColor
    • textIconGap

      protected int textIconGap
    • tabRunOverlay

      protected int tabRunOverlay
    • tabInsets

      protected Insets tabInsets
    • selectedTabPadInsets

      protected Insets selectedTabPadInsets
    • tabAreaInsets

      protected Insets tabAreaInsets
    • contentBorderInsets

      protected Insets contentBorderInsets
    • tabRuns

      protected int[] tabRuns
    • runCount

      protected int runCount
    • selectedRun

      protected int selectedRun
    • rects

      protected Rectangle[] rects
    • maxTabHeight

      protected int maxTabHeight
    • maxTabWidth

      protected int maxTabWidth
    • tabChangeListener

      protected ChangeListener tabChangeListener
    • tabComponentListener

      protected ComponentListener tabComponentListener
    • propertyChangeListener

      protected PropertyChangeListener propertyChangeListener
    • mouseListener

      protected MouseListener mouseListener
    • mouseMotionListener

      protected MouseMotionListener mouseMotionListener
    • focusListener

      protected FocusListener focusListener
    • calcRect

      protected transient Rectangle calcRect
      A rectangle used for general layout calculations in order to avoid constructing many new Rectangles on the fly.
    • oldRolloverIndex

      protected int oldRolloverIndex
    • rolloverIndex

      protected int rolloverIndex
    • roundedTabs

      protected boolean roundedTabs
    • simpleButtonBorder

      protected boolean simpleButtonBorder
  • Constructor Details

    • BaseTabbedPaneUI

      public BaseTabbedPaneUI()
  • Method Details

    • createUI

      public static ComponentUI createUI(JComponent c)
    • rotateInsets

      protected static void rotateInsets(Insets topInsets, Insets targetInsets, int targetPlacement)

      rotateInsets.

      Parameters:
      topInsets - a Insets object.
      targetInsets - a Insets object.
      targetPlacement - a Integer object.
    • assureRectsCreated

      protected void assureRectsCreated(int tabCount)

      assureRectsCreated.

      Parameters:
      tabCount - a Integer object.
    • calculateMaxTabHeight

      protected int calculateMaxTabHeight(int tabPlacement)

      calculateMaxTabHeight.

      Parameters:
      tabPlacement - a Integer object.
      Returns:
      a Integer object.
    • calculateMaxTabWidth

      protected int calculateMaxTabWidth(int tabPlacement)

      calculateMaxTabWidth.

      Parameters:
      tabPlacement - a Integer object.
      Returns:
      a Integer object.
    • calculateTabAreaHeight

      protected int calculateTabAreaHeight(int tabPlacement, int horizRunCount, int maxTabHeight)

      calculateTabAreaHeight.

      Parameters:
      tabPlacement - a Integer object.
      horizRunCount - a Integer object.
      maxTabHeight - a Integer object.
      Returns:
      a Integer object.
    • calculateTabAreaWidth

      protected int calculateTabAreaWidth(int tabPlacement, int vertRunCount, int maxTabWidth)

      calculateTabAreaWidth.

      Parameters:
      tabPlacement - a Integer object.
      vertRunCount - a Integer object.
      maxTabWidth - a Integer object.
      Returns:
      a Integer object.
    • calculateTabHeight

      protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight)

      calculateTabHeight.

      Parameters:
      tabPlacement - a Integer object.
      tabIndex - a Integer object.
      fontHeight - a Integer object.
      Returns:
      a Integer object.
    • calculateTabWidth

      protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics)

      calculateTabWidth.

      Parameters:
      tabPlacement - a Integer object.
      tabIndex - a Integer object.
      metrics - a FontMetrics object.
      Returns:
      a Integer object.
    • createChangeListener

      protected ChangeListener createChangeListener()

      createChangeListener.

      Returns:
      a ChangeListener object.
    • createComponentListener

      protected ComponentListener createComponentListener()

      createComponentListener.

      Returns:
      a ComponentListener object.
    • createFocusListener

      protected FocusListener createFocusListener()

      createFocusListener.

      Returns:
      a FocusListener object.
    • createLayoutManager

      protected LayoutManager createLayoutManager()
      Invoked by installUI to create a layout manager object to manage the JTabbedPane.
      Returns:
      a layout manager object
      See Also:
    • createMouseListener

      protected MouseListener createMouseListener()

      createMouseListener.

      Returns:
      a MouseListener object.
    • createMouseMotionListener

      protected MouseMotionListener createMouseMotionListener()

      createMouseMotionListener.

      Returns:
      a MouseMotionListener object.
    • createPropertyChangeListener

      protected PropertyChangeListener createPropertyChangeListener()

      createPropertyChangeListener.

      Returns:
      a PropertyChangeListener object.
    • expandTabRunsArray

      protected void expandTabRunsArray()

      expandTabRunsArray.

    • getClosestTab

      protected int getClosestTab(int x, int y)

      getClosestTab.

      Parameters:
      x - a Integer object.
      y - a Integer object.
      Returns:
      a Integer object.
    • getContentBorderColor

      protected Color getContentBorderColor()

      getContentBorderColor.

      Returns:
      a Color object.
    • getContentBorderColors

      protected Color[] getContentBorderColors(int tabPlacement)

      getContentBorderColors.

      Parameters:
      tabPlacement - a Integer object.
      Returns:
      an array of Color objects.
    • getContentBorderInsets

      protected Insets getContentBorderInsets(int tabPlacement)

      Getter for the field contentBorderInsets.

      Parameters:
      tabPlacement - a Integer object.
      Returns:
      a Insets object.
    • getFontMetrics

      protected FontMetrics getFontMetrics()

      getFontMetrics.

      Returns:
      a FontMetrics object.
    • getGapColor

      protected Color getGapColor(int tabIndex)

      getGapColor.

      Parameters:
      tabIndex - a Integer object.
      Returns:
      a Color object.
    • getHiBorderColor

      protected Color getHiBorderColor(int tabIndex)

      getHiBorderColor.

      Parameters:
      tabIndex - a Integer object.
      Returns:
      a Color object.
    • getIconForTab

      protected Icon getIconForTab(int tabIndex)

      getIconForTab.

      Parameters:
      tabIndex - a Integer object.
      Returns:
      a Icon object.
    • getLoBorderColor

      protected Color getLoBorderColor(int tabIndex)

      getLoBorderColor.

      Parameters:
      tabIndex - a Integer object.
      Returns:
      a Color object.
    • getMaximumSize

      public Dimension getMaximumSize(JComponent c)
      Overrides:
      getMaximumSize in class ComponentUI
    • getMinimumSize

      public Dimension getMinimumSize(JComponent c)
      Overrides:
      getMinimumSize in class ComponentUI
    • getNextTabIndex

      protected int getNextTabIndex(int base)

      getNextTabIndex.

      Parameters:
      base - a Integer object.
      Returns:
      a Integer object.
    • getNextTabIndexInRun

      protected int getNextTabIndexInRun(int tabCount, int base)

      getNextTabIndexInRun.

      Parameters:
      tabCount - a Integer object.
      base - a Integer object.
      Returns:
      a Integer object.
    • getNextTabRun

      protected int getNextTabRun(int baseRun)

      getNextTabRun.

      Parameters:
      baseRun - a Integer object.
      Returns:
      a Integer object.
    • getPreferredSize

      public Dimension getPreferredSize(JComponent c)
      Overrides:
      getPreferredSize in class ComponentUI
    • getPreviousTabIndex

      protected int getPreviousTabIndex(int base)

      getPreviousTabIndex.

      Parameters:
      base - a Integer object.
      Returns:
      a Integer object.
    • getPreviousTabIndexInRun

      protected int getPreviousTabIndexInRun(int tabCount, int base)

      getPreviousTabIndexInRun.

      Parameters:
      tabCount - a Integer object.
      base - a Integer object.
      Returns:
      a Integer object.
    • getPreviousTabRun

      protected int getPreviousTabRun(int baseRun)

      getPreviousTabRun.

      Parameters:
      baseRun - a Integer object.
      Returns:
      a Integer object.
    • getRunForTab

      protected int getRunForTab(int tabCount, int tabIndex)

      getRunForTab.

      Parameters:
      tabCount - a Integer object.
      tabIndex - a Integer object.
      Returns:
      a Integer object.
    • getSelectedTabPadInsets

      protected Insets getSelectedTabPadInsets(int tabPlacement)

      Getter for the field selectedTabPadInsets.

      Parameters:
      tabPlacement - a Integer object.
      Returns:
      a Insets object.
    • getTabAreaInsets

      protected Insets getTabAreaInsets(int tabPlacement)

      Getter for the field tabAreaInsets.

      Parameters:
      tabPlacement - a Integer object.
      Returns:
      a Insets object.
    • getTabAtLocation

      protected int getTabAtLocation(int x, int y)

      getTabAtLocation.

      Parameters:
      x - a Integer object.
      y - a Integer object.
      Returns:
      a Integer object.
    • getTabBounds

      protected Rectangle getTabBounds(int tabIndex, Rectangle dest)
      Returns the bounds of the specified tab in the coordinate space of the JTabbedPane component. This is required because the tab rects are by default defined in the coordinate space of the component where they are rendered, which could be the JTabbedPane (for WRAP_TAB_LAYOUT) or a ScrollableTabPanel (SCROLL_TAB_LAYOUT). This method should be used whenever the tab rectangle must be relative to the JTabbedPane itself and the result should be placed in a designated Rectangle object (rather than instantiating and returning a new Rectangle each time). The tab index parameter must be a valid tabbed pane tab index (0 to tab count - 1, inclusive). The destination rectangle parameter must be a valid Rectangle instance. The handling of invalid parameters is unspecified.
      Parameters:
      tabIndex - the index of the tab
      dest - the rectangle where the result should be placed
      Returns:
      the resulting rectangle
      Since:
      1.4
    • getTabBounds

      public Rectangle getTabBounds(JTabbedPane pane, int i)
      Specified by:
      getTabBounds in class TabbedPaneUI
    • getTabColors

      protected Color[] getTabColors(int tabIndex, boolean isSelected, boolean isRollover)

      getTabColors.

      Parameters:
      tabIndex - a Integer object.
      isSelected - a boolean.
      isRollover - a boolean.
      Returns:
      an array of Color objects.
    • getTabFont

      protected Font getTabFont(boolean isSelected)

      getTabFont.

      Parameters:
      isSelected - a boolean.
      Returns:
      a Font object.
    • getTabInsets

      protected Insets getTabInsets(int tabPlacement, int tabIndex)

      Getter for the field tabInsets.

      Parameters:
      tabPlacement - a Integer object.
      tabIndex - a Integer object.
      Returns:
      a Insets object.
    • getTabLabelShiftX

      protected int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected)

      getTabLabelShiftX.

      Parameters:
      tabPlacement - a Integer object.
      tabIndex - a Integer object.
      isSelected - a boolean.
      Returns:
      a Integer object.
    • getTabLabelShiftY

      protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected)

      getTabLabelShiftY.

      Parameters:
      tabPlacement - a Integer object.
      tabIndex - a Integer object.
      isSelected - a boolean.
      Returns:
      a Integer object.
    • getTabRunCount

      public int getTabRunCount(JTabbedPane pane)
      Specified by:
      getTabRunCount in class TabbedPaneUI
    • getTabRunIndent

      protected int getTabRunIndent(int tabPlacement, int run)

      getTabRunIndent.

      Parameters:
      tabPlacement - a Integer object.
      run - a Integer object.
      Returns:
      a Integer object.
    • getTabRunOffset

      protected int getTabRunOffset(int tabPlacement, int tabCount, int tabIndex, boolean forward)

      getTabRunOffset.

      Parameters:
      tabPlacement - a Integer object.
      tabCount - a Integer object.
      tabIndex - a Integer object.
      forward - a boolean.
      Returns:
      a Integer object.
    • getTabRunOverlay

      protected int getTabRunOverlay(int tabPlacement)

      Getter for the field tabRunOverlay.

      Parameters:
      tabPlacement - a Integer object.
      Returns:
      a Integer object.
    • getTextViewForTab

      protected View getTextViewForTab(int tabIndex)
      Returns the text View object required to render stylized text (HTML) for the specified tab or null if no specialized text rendering is needed for this tab. This is provided to support html rendering inside tabs.
      Parameters:
      tabIndex - the index of the tab
      Returns:
      the text view to render the tab's text or null if no specialized rendering is required
      Since:
      1.4
    • getVisibleComponent

      protected Component getVisibleComponent()

      Getter for the field visibleComponent.

      Returns:
      a Component object.
    • hasInnerBorder

      protected boolean hasInnerBorder()

      hasInnerBorder.

      Returns:
      a boolean.
    • installComponents

      protected void installComponents()
      Creates and installs any required subcomponents for the JTabbedPane. Invoked by installUI.
      Since:
      1.4
    • installDefaults

      protected void installDefaults()

      installDefaults.

    • installKeyboardActions

      protected void installKeyboardActions()

      installKeyboardActions.

    • installListeners

      protected void installListeners()

      installListeners.

    • installUI

      public void installUI(JComponent c)
      Overrides:
      installUI in class ComponentUI
    • isContentOpaque

      protected boolean isContentOpaque()

      isContentOpaque.

      Returns:
      a boolean.
    • isTabOpaque

      protected boolean isTabOpaque()

      isTabOpaque.

      Returns:
      a boolean.
    • lastTabInRun

      protected int lastTabInRun(int tabCount, int run)

      lastTabInRun.

      Parameters:
      tabCount - a Integer object.
      run - a Integer object.
      Returns:
      a Integer object.
    • layoutLabel

      protected void layoutLabel(int tabPlacement, FontMetrics metrics, int tabIndex, String title, Icon icon, Rectangle tabRect, Rectangle iconRect, Rectangle textRect, boolean isSelected)

      layoutLabel.

      Parameters:
      tabPlacement - a Integer object.
      metrics - a FontMetrics object.
      tabIndex - a Integer object.
      title - a String object.
      icon - a Icon object.
      tabRect - a Rectangle object.
      iconRect - a Rectangle object.
      textRect - a Rectangle object.
      isSelected - a boolean.
    • paint

      public void paint(Graphics g, JComponent c)
      Overrides:
      paint in class ComponentUI
    • paintBottomTabBorder

      protected void paintBottomTabBorder(int tabIndex, Graphics g, int x1, int y1, int x2, int y2, boolean isSelected)

      paintBottomTabBorder.

      Parameters:
      tabIndex - a Integer object.
      g - a Graphics object.
      x1 - a Integer object.
      y1 - a Integer object.
      x2 - a Integer object.
      y2 - a Integer object.
      isSelected - a boolean.
    • paintContentBorder

      protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)

      paintContentBorder.

      Parameters:
      g - a Graphics object.
      tabPlacement - a Integer object.
      selectedIndex - a Integer object.
      x - a Integer object.
      y - a Integer object.
      w - a Integer object.
      h - a Integer object.
    • paintFocusIndicator

      protected void paintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected)

      paintFocusIndicator.

      Parameters:
      g - a Graphics object.
      tabPlacement - a Integer object.
      rects - an array of Rectangle objects.
      tabIndex - a Integer object.
      iconRect - a Rectangle object.
      textRect - a Rectangle object.
      isSelected - a boolean.
    • paintIcon

      protected void paintIcon(Graphics g, int tabPlacement, int tabIndex, Icon icon, Rectangle iconRect, boolean isSelected)

      paintIcon.

      Parameters:
      g - a Graphics object.
      tabPlacement - a Integer object.
      tabIndex - a Integer object.
      icon - a Icon object.
      iconRect - a Rectangle object.
      isSelected - a boolean.
    • paintLeftTabBorder

      protected void paintLeftTabBorder(int tabIndex, Graphics g, int x1, int y1, int x2, int y2, boolean isSelected)

      paintLeftTabBorder.

      Parameters:
      tabIndex - a Integer object.
      g - a Graphics object.
      x1 - a Integer object.
      y1 - a Integer object.
      x2 - a Integer object.
      y2 - a Integer object.
      isSelected - a boolean.
    • paintRightTabBorder

      protected void paintRightTabBorder(int tabIndex, Graphics g, int x1, int y1, int x2, int y2, boolean isSelected)

      paintRightTabBorder.

      Parameters:
      tabIndex - a Integer object.
      g - a Graphics object.
      x1 - a Integer object.
      y1 - a Integer object.
      x2 - a Integer object.
      y2 - a Integer object.
      isSelected - a boolean.
    • paintRoundedBottomTabBorder

      protected void paintRoundedBottomTabBorder(int tabIndex, Graphics g, int x1, int y1, int x2, int y2, boolean isSelected)

      paintRoundedBottomTabBorder.

      Parameters:
      tabIndex - a Integer object.
      g - a Graphics object.
      x1 - a Integer object.
      y1 - a Integer object.
      x2 - a Integer object.
      y2 - a Integer object.
      isSelected - a boolean.
    • paintRoundedTopTabBorder

      protected void paintRoundedTopTabBorder(int tabIndex, Graphics g, int x1, int y1, int x2, int y2, boolean isSelected)

      paintRoundedTopTabBorder.

      Parameters:
      tabIndex - a Integer object.
      g - a Graphics object.
      x1 - a Integer object.
      y1 - a Integer object.
      x2 - a Integer object.
      y2 - a Integer object.
      isSelected - a boolean.
    • paintScrollContentBorder

      protected void paintScrollContentBorder(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)

      paintScrollContentBorder.

      Parameters:
      g - a Graphics object.
      tabPlacement - a Integer object.
      selectedIndex - a Integer object.
      x - a Integer object.
      y - a Integer object.
      w - a Integer object.
      h - a Integer object.
    • paintTab

      protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect)

      paintTab.

      Parameters:
      g - a Graphics object.
      tabPlacement - a Integer object.
      rects - an array of Rectangle objects.
      tabIndex - a Integer object.
      iconRect - a Rectangle object.
      textRect - a Rectangle object.
    • paintTabArea

      protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex)
      Paints the tabs in the tab area. Invoked by paint(). The graphics parameter must be a valid Graphics object. Tab placement may be either: JTabbedPane.TOP, JTabbedPane.BOTTOM, JTabbedPane.LEFT, or JTabbedPane.RIGHT. The selected index must be a valid tabbed pane tab index (0 to tab count - 1, inclusive) or -1 if no tab is currently selected. The handling of invalid parameters is unspecified.
      Parameters:
      g - the graphics object to use for rendering
      tabPlacement - the placement for the tabs within the JTabbedPane
      selectedIndex - the tab index of the selected component
      Since:
      1.4
    • paintTabBackground

      protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)

      paintTabBackground.

      Parameters:
      g - a Graphics object.
      tabPlacement - a Integer object.
      tabIndex - a Integer object.
      x - a Integer object.
      y - a Integer object.
      w - a Integer object.
      h - a Integer object.
      isSelected - a boolean.
    • paintTabBorder

      protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)

      paintTabBorder.

      Parameters:
      g - a Graphics object.
      tabPlacement - a Integer object.
      tabIndex - a Integer object.
      x - a Integer object.
      y - a Integer object.
      w - a Integer object.
      h - a Integer object.
      isSelected - a boolean.
    • paintText

      protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected)

      paintText.

      Parameters:
      g - a Graphics object.
      tabPlacement - a Integer object.
      font - a Font object.
      metrics - a FontMetrics object.
      tabIndex - a Integer object.
      title - a String object.
      textRect - a Rectangle object.
      isSelected - a boolean.
    • paintTopTabBorder

      protected void paintTopTabBorder(int tabIndex, Graphics g, int x1, int y1, int x2, int y2, boolean isSelected)

      paintTopTabBorder.

      Parameters:
      tabIndex - a Integer object.
      g - a Graphics object.
      x1 - a Integer object.
      y1 - a Integer object.
      x2 - a Integer object.
      y2 - a Integer object.
      isSelected - a boolean.
    • requestFocusForVisibleComponent

      protected boolean requestFocusForVisibleComponent()

      requestFocusForVisibleComponent.

      Returns:
      a boolean.
    • scrollableTabLayoutEnabled

      protected boolean scrollableTabLayoutEnabled()

      scrollableTabLayoutEnabled.

      Returns:
      a boolean.
    • selectAdjacentRunTab

      protected void selectAdjacentRunTab(int tabPlacement, int tabIndex, int offset)

      selectAdjacentRunTab.

      Parameters:
      tabPlacement - a Integer object.
      tabIndex - a Integer object.
      offset - a Integer object.
    • selectNextTab

      protected void selectNextTab(int current)

      selectNextTab.

      Parameters:
      current - a Integer object.
    • selectNextTabInRun

      protected void selectNextTabInRun(int current)

      selectNextTabInRun.

      Parameters:
      current - a Integer object.
    • selectPreviousTab

      protected void selectPreviousTab(int current)

      selectPreviousTab.

      Parameters:
      current - a Integer object.
    • selectPreviousTabInRun

      protected void selectPreviousTabInRun(int current)

      selectPreviousTabInRun.

      Parameters:
      current - a Integer object.
    • setVisibleComponent

      protected void setVisibleComponent(Component component)

      Setter for the field visibleComponent.

      Parameters:
      component - a Component object.
    • shouldPadTabRun

      protected boolean shouldPadTabRun(int tabPlacement, int run)

      shouldPadTabRun.

      Parameters:
      tabPlacement - a Integer object.
      run - a Integer object.
      Returns:
      a boolean.
    • shouldRotateTabRuns

      protected boolean shouldRotateTabRuns(int tabPlacement)

      shouldRotateTabRuns.

      Parameters:
      tabPlacement - a Integer object.
      Returns:
      a boolean.
    • tabForCoordinate

      public int tabForCoordinate(JTabbedPane pane, int x, int y)
      Specified by:
      tabForCoordinate in class TabbedPaneUI
    • uninstallComponents

      protected void uninstallComponents()
      Removes any installed subcomponents from the JTabbedPane. Invoked by uninstallUI.
      Since:
      1.4
    • uninstallDefaults

      protected void uninstallDefaults()

      uninstallDefaults.

    • uninstallKeyboardActions

      protected void uninstallKeyboardActions()

      uninstallKeyboardActions.

    • uninstallListeners

      protected void uninstallListeners()

      uninstallListeners.

    • uninstallUI

      public void uninstallUI(JComponent c)
      Overrides:
      uninstallUI in class ComponentUI