javax.swing.plaf.basic

Class BasicTabbedPaneUI

public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants

This is the Basic Look and Feel's UI delegate for JTabbedPane.
Nested Class Summary
classBasicTabbedPaneUI.FocusHandler
A helper class that handles focus.
classBasicTabbedPaneUI.MouseHandler
A helper class for determining if mouse presses occur inside tabs and sets the index appropriately.
classBasicTabbedPaneUI.PropertyChangeHandler
This class handles PropertyChangeEvents fired from the JTabbedPane.
classBasicTabbedPaneUI.TabbedPaneLayout
A LayoutManager responsible for placing all the tabs and the visible component inside the JTabbedPane.
classBasicTabbedPaneUI.TabSelectionHandler
This class handles ChangeEvents from the JTabbedPane.
Field Summary
protected RectanglecalcRect
A reusable rectangle.
protected InsetscontentBorderInsets
The insets around the content area.
protected ColordarkShadow
The outer bottom and right edge color for both the tab and content border.
protected KeyStrokedownKey
This is the keystroke for moving down.
protected Colorfocus
The color of the focus outline on the selected tab.
protected FocusListenerfocusListener
The listener that listens for focus events.
protected Colorhighlight
FIXME: find a use for this.
protected KeyStrokeleftKey
This is the keystroke for moving left.
protected ColorlightHighlight
The top and left edge color for both the tab and content border.
protected intmaxTabHeight
The maximum tab height.
protected intmaxTabWidth
The maximum tab width.
protected MouseListenermouseListener
The listener that listens for mouse events.
protected PropertyChangeListenerpropertyChangeListener
The listener that listens for property change events.
protected Rectangle[]rects
An array of Rectangles keeping track of the tabs' area and position.
protected KeyStrokerightKey
This is the keystroke for moving right.
protected intrunCount
The number of runs in the JTabbedPane.
protected intselectedRun
The index of the run that the selected index is in.
protected InsetsselectedTabPadInsets
The extra insets around the selected tab.
protected Colorshadow
The inner bottom and right edge color for the tab and content border.
protected InsetstabAreaInsets
The insets around the tab area.
protected ChangeListenertabChangeListener
The listener that listens for change events.
protected InsetstabInsets
The insets around each and every tab.
protected JTabbedPanetabPane
The tab pane that this UI paints.
protected inttabRunOverlay
The amount of space each run overlaps the previous by.
protected int[]tabRuns
This array keeps track of which tabs are in which run.
protected inttextIconGap
The gap between text and label
protected KeyStrokeupKey
This is the keystroke for moving up.
Constructor Summary
BasicTabbedPaneUI()
Creates a new BasicTabbedPaneUI object.
Method Summary
protected voidassureRectsCreated(int tabCount)
This method assures that enough rectangles are created given the tabCount.
protected intcalculateMaxTabHeight(int tabPlacement)
This method returns the max tab height.
protected intcalculateMaxTabWidth(int tabPlacement)
This method calculates the max tab width.
protected intcalculateTabAreaHeight(int tabPlacement, int horizRunCount, int maxTabHeight)
This method calculates the tab area height, including insets, for the given amount of runs and tab height.
protected intcalculateTabAreaWidth(int tabPlacement, int vertRunCount, int maxTabWidth)
This method calculates the tab area width, including insets, for the given amount of runs and tab width.
protected intcalculateTabHeight(int tabPlacement, int tabIndex, int fontHeight)
This method returns the tab height, including insets, for the given index and fontheight.
protected intcalculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics)
This method calculates the tab width, including insets, for the given tab index and font metrics.
protected ChangeListenercreateChangeListener()
This method creates a new ChangeListener.
protected FocusListenercreateFocusListener()
This method creates a new FocusListener.
protected LayoutManagercreateLayoutManager()
This method creates the appropriate layout manager for the JTabbedPane's current tab layout policy.
protected MouseListenercreateMouseListener()
This method creates a new MouseListener.
protected PropertyChangeListenercreatePropertyChangeListener()
This method creates a new PropertyChangeListener.
static ComponentUIcreateUI(JComponent c)
This method creates a new BasicTabbedPaneUI.
protected voidexpandTabRunsArray()
This method expands the tabRuns array to give it more room.
protected InsetsgetContentBorderInsets(int tabPlacement)
This method returns the content border insets appropriately rotated.
protected FontMetricsgetFontMetrics()
This method returns the fontmetrics for the font of the JTabbedPane.
protected IcongetIconForTab(int tabIndex)
This method returns an icon for the tab.
DimensiongetMaximumSize(JComponent c)
This method returns the maximum size of the JTabbedPane.
DimensiongetMinimumSize(JComponent c)
This method returns the minimum size of the JTabbedPane.
protected intgetNextTabIndex(int base)
This method returns the next tab index.
protected intgetNextTabIndexInRun(int tabCount, int base)
This method returns the next tab index in the run.
protected intgetNextTabRun(int baseRun)
This method returns the index of the next run.
protected intgetPreviousTabIndex(int base)
This method returns the previous tab index.
protected intgetPreviousTabIndexInRun(int tabCount, int base)
This method returns the previous tab index in the run.
protected intgetPreviousTabRun(int baseRun)
This method returns the index of the previous run.
protected intgetRolloverTab()
Retunrs the index of the tab over which the mouse is currently moving, or -1 for no tab.
protected intgetRunForTab(int tabCount, int tabIndex)
This method returns which run a particular tab belongs to.
protected InsetsgetSelectedTabPadInsets(int tabPlacement)
This method returns the selected tab pad insets appropriately rotated.
protected InsetsgetTabAreaInsets(int tabPlacement)
This method returns the tab area insets appropriately rotated.
RectanglegetTabBounds(JTabbedPane pane, int i)

This method returns the bounds of a tab for the given index and shifts it by the current scrolling offset if the tabbed pane is in scrolling tab layout mode.

Subclassses should retrievs a tab's bounds by this method if they want to find out whether the tab is currently visible.

protected RectanglegetTabBounds(int tabIndex, Rectangle dest)

This method returns the tab bounds in the given rectangle.

The returned rectangle will be shifted by the current scroll offset if the tabbed pane is in scrolling tab layout mode.

.
protected InsetsgetTabInsets(int tabPlacement, int tabIndex)
This method returns the tab insets appropriately rotated.
protected intgetTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected)
This method returns how much the label for the tab should shift in the X direction.
protected intgetTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected)
This method returns how much the label for the tab should shift in the Y direction.
intgetTabRunCount(JTabbedPane pane)
This method returns the number of runs.
protected intgetTabRunIndent(int tabPlacement, int run)
This method returns the tab run indent.
protected intgetTabRunOffset(int tabPlacement, int tabCount, int tabIndex, boolean forward)
This method calculates the offset distance for use in selectAdjacentRunTab.
protected intgetTabRunOverlay(int tabPlacement)
This method returns the tab run overlay.
protected ViewgetTextViewForTab(int tabIndex)
This method returns a view that can paint the text for the label.
protected ComponentgetVisibleComponent()
This method returns the component that is shown in the content area.
protected voidinstallComponents()
This method installs components for this JTabbedPane.
protected voidinstallDefaults()
This method installs defaults for the Look and Feel.
protected voidinstallKeyboardActions()
This method installs keyboard actions for the JTabbedPane.
protected voidinstallListeners()
This method creates and installs the listeners for this UI.
voidinstallUI(JComponent c)
This method installs the UI for the given JComponent.
protected intlastTabInRun(int tabCount, int run)
This method returns the index of the last tab in a run.
protected voidlayoutLabel(int tabPlacement, FontMetrics metrics, int tabIndex, String title, Icon icon, Rectangle tabRect, Rectangle iconRect, Rectangle textRect, boolean isSelected)
This method lays out the tab and finds the location to paint the icon and text.
protected voidnavigateSelectedTab(int direction)
This method navigates from the selected tab into the given direction.
voidpaint(Graphics g, JComponent c)
This method paints the JTabbedPane.
protected voidpaintContentBorder(Graphics g, int tabPlacement, int selectedIndex)
This method paints the border around the content area.
protected voidpaintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
This method paints the bottom edge of the content border.
protected voidpaintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
This method paints the left edge of the content border.
protected voidpaintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
This method paints the right edge of the content border.
protected voidpaintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
This method paints the top edge of the content border.
protected voidpaintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected)
This method paints the focus rectangle around the selected tab.
protected voidpaintIcon(Graphics g, int tabPlacement, int tabIndex, Icon icon, Rectangle iconRect, boolean isSelected)
This method paints the icon.
protected voidpaintTab(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect)
This method paints an individual tab.
protected voidpaintTabArea(Graphics g, int tabPlacement, int selectedIndex)
This method paints the tab area.
protected voidpaintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
This method paints the background for an individual tab.
protected voidpaintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
This method paints the border for an individual tab.
protected voidpaintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected)
This method paints the text for the given tab.
protected static voidrotateInsets(Insets topInsets, Insets targetInsets, int targetPlacement)
This method rotates the insets given a direction to rotate them in.
protected voidselectAdjacentRunTab(int tabPlacement, int tabIndex, int offset)
This method selects the correct tab given an offset from the current tab index.
protected voidselectNextTab(int current)
This method selects the next tab (regardless of runs).
protected voidselectNextTabInRun(int current)
This method selects the next tab in the run.
protected voidselectPreviousTab(int current)
This method selects the previous tab (regardless of runs).
protected voidselectPreviousTabInRun(int current)
This method selects the previous tab in the run.
protected voidsetRolloverTab(int index)
Sets the tab which should be highlighted when in rollover mode.
protected voidsetVisibleComponent(Component component)
This method sets the visible component.
protected booleanshouldPadTabRun(int tabPlacement, int run)
This method returns whether a tab run should be padded.
protected booleanshouldRotateTabRuns(int tabPlacement)
This method returns whether the tab runs should be rotated.
inttabForCoordinate(JTabbedPane pane, int x, int y)
This method returns the tab index given a coordinate.
protected voiduninstallComponents()
This method uninstalls components for this JTabbedPane.
protected voiduninstallDefaults()
This method uninstalls defaults for the Look and Feel.
protected voiduninstallKeyboardActions()
This method uninstalls keyboard actions for the JTabbedPane.
protected voiduninstallListeners()
This method removes and nulls the listeners for this UI.
voiduninstallUI(JComponent c)
This method uninstalls the UI for the given JComponent.

Field Detail

calcRect

protected Rectangle calcRect
A reusable rectangle.

contentBorderInsets

protected Insets contentBorderInsets
The insets around the content area.

darkShadow

protected Color darkShadow
The outer bottom and right edge color for both the tab and content border.

downKey

protected KeyStroke downKey

Deprecated: 1.3

This is the keystroke for moving down.

focus

protected Color focus
The color of the focus outline on the selected tab.

focusListener

protected FocusListener focusListener
The listener that listens for focus events.

highlight

protected Color highlight
FIXME: find a use for this.

leftKey

protected KeyStroke leftKey

Deprecated: 1.3

This is the keystroke for moving left.

lightHighlight

protected Color lightHighlight
The top and left edge color for both the tab and content border.

maxTabHeight

protected int maxTabHeight
The maximum tab height.

maxTabWidth

protected int maxTabWidth
The maximum tab width.

mouseListener

protected MouseListener mouseListener
The listener that listens for mouse events.

propertyChangeListener

protected PropertyChangeListener propertyChangeListener
The listener that listens for property change events.

rects

protected Rectangle[] rects
An array of Rectangles keeping track of the tabs' area and position.

rightKey

protected KeyStroke rightKey

Deprecated: 1.3

This is the keystroke for moving right.

runCount

protected int runCount
The number of runs in the JTabbedPane.

selectedRun

protected int selectedRun
The index of the run that the selected index is in.

selectedTabPadInsets

protected Insets selectedTabPadInsets
The extra insets around the selected tab.

shadow

protected Color shadow
The inner bottom and right edge color for the tab and content border.

tabAreaInsets

protected Insets tabAreaInsets
The insets around the tab area.

tabChangeListener

protected ChangeListener tabChangeListener
The listener that listens for change events.

tabInsets

protected Insets tabInsets
The insets around each and every tab.

tabPane

protected JTabbedPane tabPane
The tab pane that this UI paints.

tabRunOverlay

protected int tabRunOverlay
The amount of space each run overlaps the previous by.

tabRuns

protected int[] tabRuns
This array keeps track of which tabs are in which run.

The value at index i denotes the index of the first tab in run i.

If the value for any index (i > 0) is 0 then (i - 1) is the last run.

textIconGap

protected int textIconGap
The gap between text and label

upKey

protected KeyStroke upKey

Deprecated: 1.3

This is the keystroke for moving up.

Constructor Detail

BasicTabbedPaneUI

public BasicTabbedPaneUI()
Creates a new BasicTabbedPaneUI object.

Method Detail

assureRectsCreated

protected void assureRectsCreated(int tabCount)
This method assures that enough rectangles are created given the tabCount. The old array is copied to the new one.

Parameters: tabCount The number of tabs.

calculateMaxTabHeight

protected int calculateMaxTabHeight(int tabPlacement)
This method returns the max tab height.

Parameters: tabPlacement The JTabbedPane's tab placement.

Returns: The maximum tab height.

calculateMaxTabWidth

protected int calculateMaxTabWidth(int tabPlacement)
This method calculates the max tab width.

Parameters: tabPlacement The JTabbedPane's tab placement.

Returns: The maximum tab width.

calculateTabAreaHeight

protected int calculateTabAreaHeight(int tabPlacement, int horizRunCount, int maxTabHeight)
This method calculates the tab area height, including insets, for the given amount of runs and tab height.

Parameters: tabPlacement The JTabbedPane's tab placement. horizRunCount The number of runs. maxTabHeight The max tab height.

Returns: The tab area height.

calculateTabAreaWidth

protected int calculateTabAreaWidth(int tabPlacement, int vertRunCount, int maxTabWidth)
This method calculates the tab area width, including insets, for the given amount of runs and tab width.

Parameters: tabPlacement The JTabbedPane's tab placement. vertRunCount The number of runs. maxTabWidth The max tab width.

Returns: The tab area width.

calculateTabHeight

protected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight)
This method returns the tab height, including insets, for the given index and fontheight.

Parameters: tabPlacement The JTabbedPane's tab placement. tabIndex The index of the tab to calculate. fontHeight The font height.

Returns: This tab's height.

calculateTabWidth

protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics)
This method calculates the tab width, including insets, for the given tab index and font metrics.

Parameters: tabPlacement The JTabbedPane's tab placement. tabIndex The tab index to calculate for. metrics The font's metrics.

Returns: The tab width for the given index.

createChangeListener

protected ChangeListener createChangeListener()
This method creates a new ChangeListener.

Returns: A new ChangeListener.

createFocusListener

protected FocusListener createFocusListener()
This method creates a new FocusListener.

Returns: A new FocusListener.

createLayoutManager

protected LayoutManager createLayoutManager()
This method creates the appropriate layout manager for the JTabbedPane's current tab layout policy. If the tab layout policy is SCROLL_TAB_LAYOUT, then all the associated components that need to be created will be done so now.

Returns: A layout manager given the tab layout policy.

createMouseListener

protected MouseListener createMouseListener()
This method creates a new MouseListener.

Returns: A new MouseListener.

createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener()
This method creates a new PropertyChangeListener.

Returns: A new PropertyChangeListener.

createUI

public static ComponentUI createUI(JComponent c)
This method creates a new BasicTabbedPaneUI.

Parameters: c The JComponent to create a UI for.

Returns: A new BasicTabbedPaneUI.

expandTabRunsArray

protected void expandTabRunsArray()
This method expands the tabRuns array to give it more room. The old array is copied to the new one.

getContentBorderInsets

protected Insets getContentBorderInsets(int tabPlacement)
This method returns the content border insets appropriately rotated.

Parameters: tabPlacement The JTabbedPane's tab placement.

Returns: The content border insets.

getFontMetrics

protected FontMetrics getFontMetrics()
This method returns the fontmetrics for the font of the JTabbedPane.

Returns: The font metrics for the JTabbedPane.

getIconForTab

protected Icon getIconForTab(int tabIndex)
This method returns an icon for the tab. If the tab is disabled, it should return the disabledIcon. If it is enabled, then it should return the default icon.

Parameters: tabIndex The tab index to get an icon for.

Returns: The icon for the tab index.

getMaximumSize

public Dimension getMaximumSize(JComponent c)
This method returns the maximum size of the JTabbedPane.

Parameters: c The JComponent to find a size for.

Returns: The maximum size.

getMinimumSize

public Dimension getMinimumSize(JComponent c)
This method returns the minimum size of the JTabbedPane.

Parameters: c The JComponent to find a size for.

Returns: The minimum size.

getNextTabIndex

protected int getNextTabIndex(int base)
This method returns the next tab index.

Parameters: base The index to start from.

Returns: The next tab index.

getNextTabIndexInRun

protected int getNextTabIndexInRun(int tabCount, int base)
This method returns the next tab index in the run. If the next index is out of this run, it will return the starting tab index for the run.

Parameters: tabCount The number of tabs. base The index to start from.

Returns: The next tab index in the run.

getNextTabRun

protected int getNextTabRun(int baseRun)
This method returns the index of the next run.

Parameters: baseRun The run to start from.

Returns: The index of the next run.

getPreviousTabIndex

protected int getPreviousTabIndex(int base)
This method returns the previous tab index.

Parameters: base The index to start from.

Returns: The previous tab index.

getPreviousTabIndexInRun

protected int getPreviousTabIndexInRun(int tabCount, int base)
This method returns the previous tab index in the run. If the previous index is out of this run, it will return the last index for the run.

Parameters: tabCount The number of tabs. base The index to start from.

Returns: The previous tab index in the run.

getPreviousTabRun

protected int getPreviousTabRun(int baseRun)
This method returns the index of the previous run.

Parameters: baseRun The run to start from.

Returns: The index of the previous run.

getRolloverTab

protected int getRolloverTab()
Retunrs the index of the tab over which the mouse is currently moving, or -1 for no tab.

Returns: the index of the tab over which the mouse is currently moving, or -1 for no tab

Since: 1.5

getRunForTab

protected int getRunForTab(int tabCount, int tabIndex)
This method returns which run a particular tab belongs to.

Parameters: tabCount The number of tabs. tabIndex The tab to find.

Returns: The tabRuns index that it belongs to.

getSelectedTabPadInsets

protected Insets getSelectedTabPadInsets(int tabPlacement)
This method returns the selected tab pad insets appropriately rotated.

Parameters: tabPlacement The JTabbedPane's tab placement.

Returns: The selected tab pad insets.

getTabAreaInsets

protected Insets getTabAreaInsets(int tabPlacement)
This method returns the tab area insets appropriately rotated.

Parameters: tabPlacement The JTabbedPane's tab placement.

Returns: The tab area insets.

getTabBounds

public Rectangle getTabBounds(JTabbedPane pane, int i)

This method returns the bounds of a tab for the given index and shifts it by the current scrolling offset if the tabbed pane is in scrolling tab layout mode.

Subclassses should retrievs a tab's bounds by this method if they want to find out whether the tab is currently visible.

Parameters: pane The JTabbedPane. i The index to look for.

Returns: The bounds of the tab with the given index.

getTabBounds

protected Rectangle getTabBounds(int tabIndex, Rectangle dest)

This method returns the tab bounds in the given rectangle.

The returned rectangle will be shifted by the current scroll offset if the tabbed pane is in scrolling tab layout mode.

.

Parameters: tabIndex The index to get bounds for. dest The rectangle to store bounds in.

Returns: The rectangle passed in.

getTabInsets

protected Insets getTabInsets(int tabPlacement, int tabIndex)
This method returns the tab insets appropriately rotated.

Parameters: tabPlacement The JTabbedPane's tab placement. tabIndex The tab index.

Returns: The tab insets for the given index.

getTabLabelShiftX

protected int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected)
This method returns how much the label for the tab should shift in the X direction.

Parameters: tabPlacement The JTabbedPane's tab placement. tabIndex The tab index being painted. isSelected Whether this tab is selected.

Returns: The amount the label should shift by in the X direction.

getTabLabelShiftY

protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected)
This method returns how much the label for the tab should shift in the Y direction.

Parameters: tabPlacement The JTabbedPane's tab placement. tabIndex The tab index being painted. isSelected Whether this tab is selected.

Returns: The amount the label should shift by in the Y direction.

getTabRunCount

public int getTabRunCount(JTabbedPane pane)
This method returns the number of runs.

Parameters: pane The JTabbedPane.

Returns: The number of runs.

getTabRunIndent

protected int getTabRunIndent(int tabPlacement, int run)
This method returns the tab run indent. It is used in WRAP_TAB_LAYOUT and makes each tab run start indented by a certain amount.

Parameters: tabPlacement The JTabbedPane's tab placement. run The run to get indent for.

Returns: The amount a run should be indented.

getTabRunOffset

protected int getTabRunOffset(int tabPlacement, int tabCount, int tabIndex, boolean forward)
This method calculates the offset distance for use in selectAdjacentRunTab. The offset returned will be a difference in the y coordinate between the run in the desired direction and the current run (for tabPlacement in TOP or BOTTOM). Use x coordinate for LEFT and RIGHT.

Parameters: tabPlacement The JTabbedPane's tab placement. tabCount The number of tabs. tabIndex The starting index. forward If forward, the run in the desired direction will be the next run.

Returns: The offset between the two runs.

getTabRunOverlay

protected int getTabRunOverlay(int tabPlacement)
This method returns the tab run overlay.

Parameters: tabPlacement The JTabbedPane's tab placement.

Returns: The tab run overlay.

getTextViewForTab

protected View getTextViewForTab(int tabIndex)
This method returns a view that can paint the text for the label.

Parameters: tabIndex The tab index to get a view for.

Returns: The view for the tab index.

getVisibleComponent

protected Component getVisibleComponent()
This method returns the component that is shown in the content area.

Returns: The component that is shown in the content area.

installComponents

protected void installComponents()
This method installs components for this JTabbedPane.

installDefaults

protected void installDefaults()
This method installs defaults for the Look and Feel.

installKeyboardActions

protected void installKeyboardActions()
This method installs keyboard actions for the JTabbedPane.

installListeners

protected void installListeners()
This method creates and installs the listeners for this UI.

installUI

public void installUI(JComponent c)
This method installs the UI for the given JComponent.

Parameters: c The JComponent to install the UI for.

lastTabInRun

protected int lastTabInRun(int tabCount, int run)
This method returns the index of the last tab in a run.

Parameters: tabCount The number of tabs. run The run to check.

Returns: The last tab in the given run.

layoutLabel

protected void layoutLabel(int tabPlacement, FontMetrics metrics, int tabIndex, String title, Icon icon, Rectangle tabRect, Rectangle iconRect, Rectangle textRect, boolean isSelected)
This method lays out the tab and finds the location to paint the icon and text.

Parameters: tabPlacement The JTabbedPane's tab placement. metrics The font metrics for the font to paint with. tabIndex The tab index to paint. title The string painted. icon The icon painted. tabRect The tab bounds. iconRect The calculated icon bounds. textRect The calculated text bounds. isSelected Whether this tab is selected.

navigateSelectedTab

protected void navigateSelectedTab(int direction)
This method navigates from the selected tab into the given direction. As a result, a new tab will be selected (if possible).

Parameters: direction The direction to navigate in.

paint

public void paint(Graphics g, JComponent c)
This method paints the JTabbedPane.

Parameters: g The Graphics object to paint with. c The JComponent to paint.

paintContentBorder

protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex)
This method paints the border around the content area.

Parameters: g The Graphics object to paint with. tabPlacement The JTabbedPane's tab placement. selectedIndex The index of the selected tab.

paintContentBorderBottomEdge

protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
This method paints the bottom edge of the content border.

Parameters: g The Graphics object to paint with. tabPlacement The JTabbedPane's tab placement. selectedIndex The selected tab index. x The x coordinate for the content area. y The y coordinate for the content area. w The width of the content area. h The height of the content area.

paintContentBorderLeftEdge

protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
This method paints the left edge of the content border.

Parameters: g The Graphics object to paint with. tabPlacement The JTabbedPane's tab placement. selectedIndex The selected tab index. x The x coordinate for the content area. y The y coordinate for the content area. w The width of the content area. h The height of the content area.

paintContentBorderRightEdge

protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
This method paints the right edge of the content border.

Parameters: g The Graphics object to paint with. tabPlacement The JTabbedPane's tab placement. selectedIndex The selected tab index. x The x coordinate for the content area. y The y coordinate for the content area. w The width of the content area. h The height of the content area.

paintContentBorderTopEdge

protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
This method paints the top edge of the content border.

Parameters: g The Graphics object to paint with. tabPlacement The JTabbedPane's tab placement. selectedIndex The selected tab index. x The x coordinate for the content area. y The y coordinate for the content area. w The width of the content area. h The height of the content area.

paintFocusIndicator

protected void paintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected)
This method paints the focus rectangle around the selected tab.

Parameters: g The Graphics object to paint with. tabPlacement The JTabbedPane's tab placement. rects The array of rectangles keeping track of size and position. tabIndex The tab index. iconRect The icon bounds. textRect The text bounds. isSelected Whether this tab is selected.

paintIcon

protected void paintIcon(Graphics g, int tabPlacement, int tabIndex, Icon icon, Rectangle iconRect, boolean isSelected)
This method paints the icon.

Parameters: g The Graphics object to paint. tabPlacement The JTabbedPane's tab placement. tabIndex The tab index to paint. icon The icon to paint. iconRect The bounds of the icon. isSelected Whether this tab is selected.

paintTab

protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect)
This method paints an individual tab.

Parameters: g The Graphics object to paint with. tabPlacement The JTabbedPane's tab placement. rects The array of rectangles that keep the size and position of the tabs. tabIndex The tab index to paint. iconRect The rectangle to use for the icon. textRect The rectangle to use for the text.

paintTabArea

protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex)
This method paints the tab area. This includes painting the rectangles that make up the tabs.

Parameters: g The Graphics object to paint with. tabPlacement The JTabbedPane's tab placement. selectedIndex The selected index.

paintTabBackground

protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
This method paints the background for an individual tab.

Parameters: g The Graphics object to paint with. tabPlacement The JTabbedPane's tab placement. tabIndex The tab index. x The x position of the tab. y The y position of the tab. w The width of the tab. h The height of the tab. isSelected Whether the tab is selected.

paintTabBorder

protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
This method paints the border for an individual tab.

Parameters: g The Graphics object to paint with. tabPlacement The JTabbedPane's tab placement. tabIndex The tab index. x The x position of the tab. y The y position of the tab. w The width of the tab. h The height of the tab. isSelected Whether the tab is selected.

paintText

protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected)
This method paints the text for the given tab.

Parameters: g The Graphics object to paint with. tabPlacement The JTabbedPane's tab placement. font The font to paint with. metrics The fontmetrics of the given font. tabIndex The tab index. title The string to paint. textRect The bounds of the string. isSelected Whether this tab is selected.

rotateInsets

protected static void rotateInsets(Insets topInsets, Insets targetInsets, int targetPlacement)
This method rotates the insets given a direction to rotate them in. Target placement should be one of TOP, LEFT, BOTTOM, RIGHT. The rotated insets will be stored in targetInsets. Passing in TOP as the direction does nothing. Passing in LEFT switches top and left, right and bottom. Passing in BOTTOM switches top and bottom. Passing in RIGHT switches top for left, left for bottom, bottom for right, and right for top.

Parameters: topInsets The reference insets. targetInsets An Insets object to store the new insets. targetPlacement The rotation direction.

selectAdjacentRunTab

protected void selectAdjacentRunTab(int tabPlacement, int tabIndex, int offset)
This method selects the correct tab given an offset from the current tab index. If the tab placement is TOP or BOTTOM, the offset will be in the y direction, otherwise, it will be in the x direction. A new coordinate will be found by adding the offset to the current location of the tab. The tab that the new location will be selected.

Parameters: tabPlacement The JTabbedPane's tab placement. tabIndex The tab to start from. offset The coordinate offset.

selectNextTab

protected void selectNextTab(int current)
This method selects the next tab (regardless of runs).

Parameters: current The current selected index.

selectNextTabInRun

protected void selectNextTabInRun(int current)
This method selects the next tab in the run.

Parameters: current The current selected index.

selectPreviousTab

protected void selectPreviousTab(int current)
This method selects the previous tab (regardless of runs).

Parameters: current The current selected index.

selectPreviousTabInRun

protected void selectPreviousTabInRun(int current)
This method selects the previous tab in the run.

Parameters: current The current selected index.

setRolloverTab

protected void setRolloverTab(int index)
Sets the tab which should be highlighted when in rollover mode. And index of -1 means that the rollover tab is deselected (i.e. the mouse is outside of the tabarea).

Parameters: index the index of the tab that is under the mouse, -1 for no tab

Since: 1.5

setVisibleComponent

protected void setVisibleComponent(Component component)
This method sets the visible component.

Parameters: component The component to be set visible.

shouldPadTabRun

protected boolean shouldPadTabRun(int tabPlacement, int run)
This method returns whether a tab run should be padded.

Parameters: tabPlacement The JTabbedPane's tab placement. run The run to check.

Returns: Whether the given run should be padded.

shouldRotateTabRuns

protected boolean shouldRotateTabRuns(int tabPlacement)
This method returns whether the tab runs should be rotated.

Parameters: tabPlacement The JTabbedPane's tab placement.

Returns: Whether runs should be rotated.

tabForCoordinate

public int tabForCoordinate(JTabbedPane pane, int x, int y)
This method returns the tab index given a coordinate.

Parameters: pane The JTabbedPane. x The x coordinate. y The y coordinate.

Returns: The tab index that the coordinate lands in.

uninstallComponents

protected void uninstallComponents()
This method uninstalls components for this JTabbedPane.

uninstallDefaults

protected void uninstallDefaults()
This method uninstalls defaults for the Look and Feel.

uninstallKeyboardActions

protected void uninstallKeyboardActions()
This method uninstalls keyboard actions for the JTabbedPane.

uninstallListeners

protected void uninstallListeners()
This method removes and nulls the listeners for this UI.

uninstallUI

public void uninstallUI(JComponent c)
This method uninstalls the UI for the given JComponent.

Parameters: c The JComponent to uninstall the UI for.