public class

BasicTabbedPaneUI

extends TabbedPaneUI
implements SwingConstants
java.lang.Object
   ↳ javax.swing.plaf.ComponentUI
     ↳ javax.swing.plaf.TabbedPaneUI
       ↳ javax.swing.plaf.basic.BasicTabbedPaneUI
Known Direct Subclasses

Class Overview

A Basic L&F implementation of TabbedPaneUI.

Summary

Nested Classes
class BasicTabbedPaneUI.FocusHandler This class should be treated as a "protected" inner class. 
class BasicTabbedPaneUI.MouseHandler This class should be treated as a "protected" inner class. 
class BasicTabbedPaneUI.PropertyChangeHandler This class should be treated as a "protected" inner class. 
class BasicTabbedPaneUI.TabSelectionHandler This class should be treated as a "protected" inner class. 
class BasicTabbedPaneUI.TabbedPaneLayout This class should be treated as a "protected" inner class. 
[Expand]
Inherited Constants
From interface javax.swing.SwingConstants
Fields
protected Rectangle calcRect A rectangle used for general layout calculations in order to avoid constructing many new Rectangles on the fly.
protected Insets contentBorderInsets
protected Color darkShadow
protected KeyStroke downKey This field is deprecated. As of Java 2 platform v1.3.
protected Color focus
protected FocusListener focusListener
protected Color highlight
protected KeyStroke leftKey This field is deprecated. As of Java 2 platform v1.3.
protected Color lightHighlight
protected int maxTabHeight
protected int maxTabWidth
protected MouseListener mouseListener
protected PropertyChangeListener propertyChangeListener
protected Rectangle[] rects
protected KeyStroke rightKey This field is deprecated. As of Java 2 platform v1.3.
protected int runCount
protected int selectedRun
protected Insets selectedTabPadInsets
protected Color shadow
protected Insets tabAreaInsets
protected ChangeListener tabChangeListener
protected Insets tabInsets
protected JTabbedPane tabPane
protected int tabRunOverlay
protected int[] tabRuns
protected int textIconGap
protected KeyStroke upKey This field is deprecated. As of Java 2 platform v1.3.
Public Constructors
BasicTabbedPaneUI()
Public Methods
static ComponentUI createUI(JComponent c)
int getBaseline(JComponent c, int width, int height)
Returns the baseline.
Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
Returns an enum indicating how the baseline of the component changes as the size changes.
Dimension getMaximumSize(JComponent c)
Returns the specified component's maximum size appropriate for the look and feel.
Dimension getMinimumSize(JComponent c)
Returns the specified component's minimum size appropriate for the look and feel.
Rectangle getTabBounds(JTabbedPane pane, int i)
Returns the bounds of the specified tab index.
int getTabRunCount(JTabbedPane pane)
void installUI(JComponent c)
Configures the specified component appropriate for the look and feel.
void paint(Graphics g, JComponent c)
Paints the specified component appropriate for the look and feel.
int tabForCoordinate(JTabbedPane pane, int x, int y)
Returns the tab index which intersects the specified point in the JTabbedPane's coordinate space.
void uninstallUI(JComponent c)
Reverses configuration which was done on the specified component during installUI.
Protected Methods
void assureRectsCreated(int tabCount)
int calculateMaxTabHeight(int tabPlacement)
int calculateMaxTabWidth(int tabPlacement)
int calculateTabAreaHeight(int tabPlacement, int horizRunCount, int maxTabHeight)
int calculateTabAreaWidth(int tabPlacement, int vertRunCount, int maxTabWidth)
int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight)
int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics)
ChangeListener createChangeListener()
FocusListener createFocusListener()
LayoutManager createLayoutManager()
Invoked by installUI to create a layout manager object to manage the JTabbedPane.
MouseListener createMouseListener()
PropertyChangeListener createPropertyChangeListener()
JButton createScrollButton(int direction)
Creates and returns a JButton that will provide the user with a way to scroll the tabs in a particular direction.
void expandTabRunsArray()
int getBaseline(int tab)
Returns the baseline for the specified tab.
int getBaselineOffset()
Returns the amount the baseline is offset by.
Insets getContentBorderInsets(int tabPlacement)
int getFocusIndex()
Returns the index of the tab that has focus.
FontMetrics getFontMetrics()
Icon getIconForTab(int tabIndex)
int getNextTabIndex(int base)
int getNextTabIndexInRun(int tabCount, int base)
int getNextTabRun(int baseRun)
int getPreviousTabIndex(int base)
int getPreviousTabIndexInRun(int tabCount, int base)
int getPreviousTabRun(int baseRun)
int getRolloverTab()
Returns the tab the mouse is currently over, or -1 if the mouse is no longer over any tab.
int getRunForTab(int tabCount, int tabIndex)
Insets getSelectedTabPadInsets(int tabPlacement)
Insets getTabAreaInsets(int tabPlacement)
Rectangle getTabBounds(int tabIndex, Rectangle dest)
Returns the bounds of the specified tab in the coordinate space of the JTabbedPane component.
Insets getTabInsets(int tabPlacement, int tabIndex)
int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected)
int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected)
int getTabRunIndent(int tabPlacement, int run)
int getTabRunOffset(int tabPlacement, int tabCount, int tabIndex, boolean forward)
int getTabRunOverlay(int tabPlacement)
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.
Component getVisibleComponent()
void installComponents()
Creates and installs any required subcomponents for the JTabbedPane.
void installDefaults()
void installKeyboardActions()
void installListeners()
int lastTabInRun(int tabCount, int run)
void layoutLabel(int tabPlacement, FontMetrics metrics, int tabIndex, String title, Icon icon, Rectangle tabRect, Rectangle iconRect, Rectangle textRect, boolean isSelected)
void navigateSelectedTab(int direction)
void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex)
void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
void paintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
void paintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected)
void paintIcon(Graphics g, int tabPlacement, int tabIndex, Icon icon, Rectangle iconRect, boolean isSelected)
void paintTab(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect)
void paintTabArea(Graphics g, int tabPlacement, int selectedIndex)
Paints the tabs in the tab area.
void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
this function draws the border around each tab note that this function does now draw the background of the tab.
void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected)
static void rotateInsets(Insets topInsets, Insets targetInsets, int targetPlacement)
void selectAdjacentRunTab(int tabPlacement, int tabIndex, int offset)
void selectNextTab(int current)
void selectNextTabInRun(int current)
void selectPreviousTab(int current)
void selectPreviousTabInRun(int current)
void setRolloverTab(int index)
Sets the tab the mouse is currently over to index.
void setVisibleComponent(Component component)
boolean shouldPadTabRun(int tabPlacement, int run)
boolean shouldRotateTabRuns(int tabPlacement)
void uninstallComponents()
Removes any installed subcomponents from the JTabbedPane.
void uninstallDefaults()
void uninstallKeyboardActions()
void uninstallListeners()
[Expand]
Inherited Methods
From class javax.swing.plaf.TabbedPaneUI
From class javax.swing.plaf.ComponentUI
From class java.lang.Object

Fields

protected Rectangle calcRect

A rectangle used for general layout calculations in order to avoid constructing many new Rectangles on the fly.

protected Insets contentBorderInsets

protected Color darkShadow

protected KeyStroke downKey

This field is deprecated.
As of Java 2 platform v1.3.

As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.

protected Color focus

protected FocusListener focusListener

protected Color highlight

protected KeyStroke leftKey

This field is deprecated.
As of Java 2 platform v1.3.

As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.

protected Color lightHighlight

protected int maxTabHeight

protected int maxTabWidth

protected MouseListener mouseListener

protected PropertyChangeListener propertyChangeListener

protected Rectangle[] rects

protected KeyStroke rightKey

This field is deprecated.
As of Java 2 platform v1.3.

As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.

protected int runCount

protected int selectedRun

protected Insets selectedTabPadInsets

protected Color shadow

protected Insets tabAreaInsets

protected ChangeListener tabChangeListener

protected Insets tabInsets

protected JTabbedPane tabPane

protected int tabRunOverlay

protected int[] tabRuns

protected int textIconGap

protected KeyStroke upKey

This field is deprecated.
As of Java 2 platform v1.3.

As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.

Public Constructors

public BasicTabbedPaneUI ()

Public Methods

public static ComponentUI createUI (JComponent c)

public int getBaseline (JComponent c, int width, int height)

Returns the baseline.

Parameters
c JComponent baseline is being requested for
width the width to get the baseline for
height the height to get the baseline for
Returns
  • baseline or a value < 0 indicating there is no reasonable baseline

public Component.BaselineResizeBehavior getBaselineResizeBehavior (JComponent c)

Returns an enum indicating how the baseline of the component changes as the size changes.

Parameters
c JComponent to return baseline resize behavior for
Returns
  • an enum indicating how the baseline changes as the component size changes

public Dimension getMaximumSize (JComponent c)

Returns the specified component's maximum size appropriate for the look and feel. If null is returned, the maximum size will be calculated by the component's layout manager instead (this is the preferred approach for any component with a specific layout manager installed). The default implementation of this method invokes getPreferredSize and returns that value.

Parameters
c the component whose maximum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
Returns
  • a Dimension object or null

public Dimension getMinimumSize (JComponent c)

Returns the specified component's minimum size appropriate for the look and feel. If null is returned, the minimum size will be calculated by the component's layout manager instead (this is the preferred approach for any component with a specific layout manager installed). The default implementation of this method invokes getPreferredSize and returns that value.

Parameters
c the component whose minimum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
Returns
  • a Dimension object or null

public Rectangle getTabBounds (JTabbedPane pane, int i)

Returns the bounds of the specified tab index. The bounds are with respect to the JTabbedPane's coordinate space.

public int getTabRunCount (JTabbedPane pane)

public void installUI (JComponent c)

Configures the specified component appropriate for the look and feel. This method is invoked when the ComponentUI instance is being installed as the UI delegate on the specified component. This method should completely configure the component for the look and feel, including the following:

  1. Install any default property values for color, fonts, borders, icons, opacity, etc. on the component. Whenever possible, property values initialized by the client program should not be overridden.
  2. Install a LayoutManager on the component if necessary.
  3. Create/add any required sub-components to the component.
  4. Create/install event listeners on the component.
  5. Create/install a PropertyChangeListener on the component in order to detect and respond to component property changes appropriately.
  6. Install keyboard UI (mnemonics, traversal, etc.) on the component.
  7. Initialize any appropriate instance data.

Parameters
c the component where this UI delegate is being installed

public void paint (Graphics g, JComponent c)

Paints the specified component appropriate for the look and feel. This method is invoked from the ComponentUI.update method when the specified component is being painted. Subclasses should override this method and use the specified Graphics object to render the content of the component.

Parameters
g the Graphics context in which to paint
c the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components

public int tabForCoordinate (JTabbedPane pane, int x, int y)

Returns the tab index which intersects the specified point in the JTabbedPane's coordinate space.

public void uninstallUI (JComponent c)

Reverses configuration which was done on the specified component during installUI. This method is invoked when this UIComponent instance is being removed as the UI delegate for the specified component. This method should undo the configuration performed in installUI, being careful to leave the JComponent instance in a clean state (no extraneous listeners, look-and-feel-specific property objects, etc.). This should include the following:

  1. Remove any UI-set borders from the component.
  2. Remove any UI-set layout managers on the component.
  3. Remove any UI-added sub-components from the component.
  4. Remove any UI-added event/property listeners from the component.
  5. Remove any UI-installed keyboard UI from the component.
  6. Nullify any allocated instance data objects to allow for GC.

Parameters
c the component from which this UI delegate is being removed; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components

Protected Methods

protected void assureRectsCreated (int tabCount)

protected int calculateMaxTabHeight (int tabPlacement)

protected int calculateMaxTabWidth (int tabPlacement)

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

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

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

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

protected ChangeListener createChangeListener ()

protected FocusListener createFocusListener ()

protected LayoutManager createLayoutManager ()

Invoked by installUI to create a layout manager object to manage the JTabbedPane.

Returns
  • a layout manager object

protected MouseListener createMouseListener ()

protected PropertyChangeListener createPropertyChangeListener ()

protected JButton createScrollButton (int direction)

Creates and returns a JButton that will provide the user with a way to scroll the tabs in a particular direction. The returned JButton must be instance of UIResource.

Parameters
direction One of the SwingConstants constants: SOUTH, NORTH, EAST or WEST
Returns
  • Widget for user to
Throws
IllegalArgumentException if direction is not one of NORTH, SOUTH, EAST or WEST

protected void expandTabRunsArray ()

protected int getBaseline (int tab)

Returns the baseline for the specified tab.

Parameters
tab index of tab to get baseline for
Returns
  • baseline or a value < 0 indicating there is no reasonable baseline
Throws
IndexOutOfBoundsException if index is out of range (index < 0 || index >= tab count)

protected int getBaselineOffset ()

Returns the amount the baseline is offset by. This is typically the same as getTabLabelShiftY.

Returns
  • amount to offset the baseline by

protected Insets getContentBorderInsets (int tabPlacement)

protected int getFocusIndex ()

Returns the index of the tab that has focus.

Returns
  • index of tab that has focus

protected FontMetrics getFontMetrics ()

protected Icon getIconForTab (int tabIndex)

protected int getNextTabIndex (int base)

protected int getNextTabIndexInRun (int tabCount, int base)

protected int getNextTabRun (int baseRun)

protected int getPreviousTabIndex (int base)

protected int getPreviousTabIndexInRun (int tabCount, int base)

protected int getPreviousTabRun (int baseRun)

protected int getRolloverTab ()

Returns the tab the mouse is currently over, or -1 if the mouse is no longer over any tab.

Returns
  • the tab the mouse is currently over, or -1 if the mouse is no longer over any tab

protected int getRunForTab (int tabCount, int tabIndex)

protected Insets getSelectedTabPadInsets (int tabPlacement)

protected Insets getTabAreaInsets (int tabPlacement)

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

protected Insets getTabInsets (int tabPlacement, int tabIndex)

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

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

protected int getTabRunIndent (int tabPlacement, int run)

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

protected int getTabRunOverlay (int tabPlacement)

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

protected Component getVisibleComponent ()

protected void installComponents ()

Creates and installs any required subcomponents for the JTabbedPane. Invoked by installUI.

protected void installDefaults ()

protected void installKeyboardActions ()

protected void installListeners ()

protected int lastTabInRun (int tabCount, int run)

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

protected void navigateSelectedTab (int direction)

protected void paintContentBorder (Graphics g, int tabPlacement, int selectedIndex)

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

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

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

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

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

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

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

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

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

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

this function draws the border around each tab note that this function does now draw the background of the tab. that is done elsewhere

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

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

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

protected void selectNextTab (int current)

protected void selectNextTabInRun (int current)

protected void selectPreviousTab (int current)

protected void selectPreviousTabInRun (int current)

protected void setRolloverTab (int index)

Sets the tab the mouse is currently over to index. index will be -1 if the mouse is no longer over any tab. No checking is done to ensure the passed in index identifies a valid tab.

Parameters
index Index of the tab the mouse is over.

protected void setVisibleComponent (Component component)

protected boolean shouldPadTabRun (int tabPlacement, int run)

protected boolean shouldRotateTabRuns (int tabPlacement)

protected void uninstallComponents ()

Removes any installed subcomponents from the JTabbedPane. Invoked by uninstallUI.

protected void uninstallDefaults ()

protected void uninstallKeyboardActions ()

protected void uninstallListeners ()