APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.plaf.basic

public Class BasicTabbedPaneUI

extends TabbedPaneUI
implements SwingConstants
Class Inheritance
All Implemented Interfaces
javax.swing.SwingConstants
Known Direct Subclasses
javax.swing.plaf.metal.MetalTabbedPaneUI, javax.swing.plaf.synth.SynthTabbedPaneUI, com.sun.java.swing.plaf.motif.MotifTabbedPaneUI
Imports
java.awt.Color, .Component, .Container, .Dimension, .Font, .FontMetrics, .Graphics, .Graphics2D, .Insets, .LayoutManager, .Point, .Polygon, .Rectangle, .Shape, java.awt.event.ActionEvent, .ActionListener, .ContainerEvent, .ContainerListener, .FocusAdapter, .FocusEvent, .FocusListener, .MouseAdapter, .MouseEvent, .MouseListener, .MouseMotionListener, java.beans.PropertyChangeEvent, .PropertyChangeListener, java.util.Hashtable, .Vector, javax.swing.Action, .ActionMap, .Icon, .InputMap, .JButton, .JComponent, .JPanel, .JTabbedPane, .JViewport, .KeyStroke, .LookAndFeel, .SwingConstants, .SwingUtilities, .UIManager, javax.swing.event.ChangeEvent, .ChangeListener, javax.swing.plaf.ComponentInputMapUIResource, .ComponentUI, .TabbedPaneUI, .UIResource, javax.swing.text.View, sun.swing.DefaultLookup, .SwingUtilities2, .UIAction

A Basic L&F implementation of TabbedPaneUI.
Authors
Amy Fowler, Philip Milne, Steve Wilson, Tom Santos, Dave Moore

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private class
public class
BasicTabbedPaneUI.FocusHandler

This class should be treated as a "protected" inner class.

private class
public class
BasicTabbedPaneUI.MouseHandler

This class should be treated as a "protected" inner class.

public class
BasicTabbedPaneUI.PropertyChangeHandler

This class should be treated as a "protected" inner class.

private static class
private class
private class
private class
public class
BasicTabbedPaneUI.TabbedPaneLayout

This class should be treated as a "protected" inner class.

private class
private class
public class
BasicTabbedPaneUI.TabSelectionHandler

This class should be treated as a "protected" inner class.

Field Summary

Modifier and TypeField and Description
private int
protected transient Rectangle
calcRect

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

private boolean
protected Insets
contentBorderInsets

Content border insets

private boolean
private static final int
private Insets
private Insets
protected Color
darkShadow

Dark shadow color

protected KeyStroke
downKey

Deprecated As of Java 2 platform v1.3.
As of Java 2 platform v1.3 this previously undocumented field is no longer used.
protected Color
focus

Focus color

private int
focusIndex

Tab that has focus.

protected FocusListener
focusListener

Focus change listener

private BasicTabbedPaneUI.Handler
handler

Combined listeners.

protected Color
highlight

Highlight color

private Vector<View>
private boolean
isRunsDirty

This is set to true when a component is added/removed from the tab pane and set to false when layout happens.

protected KeyStroke
leftKey

Deprecated As of Java 2 platform v1.3.
As of Java 2 platform v1.3 this previously undocumented field is no longer used.
protected Color
lightHighlight

Light highlight color

protected int
maxTabHeight

Maximum tab height

protected int
maxTabWidth

Maximum tab width

private InputMap
mnemonicInputMap

InputMap used for mnemonics.

private Hashtable<Integer, Integer>
protected MouseListener
mouseListener

Mouse change listener

protected PropertyChangeListener
propertyChangeListener

Property change listener

protected Rectangle[]
rects

Tab rects

protected KeyStroke
rightKey

Deprecated As of Java 2 platform v1.3.
As of Java 2 platform v1.3 this previously undocumented field is no longer used.
private int
rolloverTabIndex

Index of the tab the mouse is over.

protected int
runCount

Run count

private Color
protected int
selectedRun

Selected run

protected Insets
selectedTabPadInsets

Selected tab insets

protected Color
shadow

Shadow color

protected Insets
tabAreaInsets

Tab area insets

protected ChangeListener
tabChangeListener

Tab change listener

private BasicTabbedPaneUI.TabContainer
protected Insets
tabInsets

Tab insets

protected JTabbedPane
tabPane

The tab pane

protected int
tabRunOverlay

Tab run overlay

protected int[]
tabRuns

Tab runs

private BasicTabbedPaneUI.ScrollableTabSupport
private boolean
private boolean
protected int
textIconGap

Text icon gap

protected KeyStroke
upKey

Deprecated As of Java 2 platform v1.3.
As of Java 2 platform v1.3 this previously undocumented field is no longer used.
private Component
private static int[]
private static int[]

Constructor Summary

AccessConstructor and Description
public
BasicTabbedPaneUI()

Constructs a BasicTabbedPaneUI.

Method Summary

Modifier and TypeMethod and Description
private void
addMnemonic(int index, int mnemonic)

Adds the specified mnemonic at the specified index.

protected void
assureRectsCreated(int
the tab count
tabCount
)

Assures the tab rectangles are created.

private void
private int
protected int

Returns:

the maximum tab height
calculateMaxTabHeight
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
)

Calculates the maximum tab height.

protected int

Returns:

the maximum tab width
calculateMaxTabWidth
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
)

Calculates the maximum tab width.

protected int

Returns:

the tab area height
calculateTabAreaHeight
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
horizontal run count
horizRunCount
,
int
maximum tab height
maxTabHeight
)

Calculates the tab area height.

protected int

Returns:

the tab area width
calculateTabAreaWidth
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
vertical run count
vertRunCount
,
int
maximum tab width
maxTabWidth
)

Calculates the tab area width.

protected int

Returns:

the tab height
calculateTabHeight
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the index of the tab with respect to other tabs
tabIndex
,
int
the font height
fontHeight
)

Calculates the tab height.

protected int

Returns:

the tab width
calculateTabWidth
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the index of the tab with respect to other tabs
tabIndex
,
FontMetrics
the font metrics
metrics
)

Calculates the tab width.

protected ChangeListener

Returns:

a change listener
createChangeListener
()

Creates a change listener.

private static Polygon
createCroppedTabShape(int tabPlacement, Rectangle tabRect, int cropline)

protected FocusListener

Returns:

a focus listener
createFocusListener
()

Creates a focus listener.

private Vector<View>
protected LayoutManager

Returns:

a layout manager object
createLayoutManager
()

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

protected MouseListener

Returns:

a mouse listener
createMouseListener
()

Creates a mouse listener.

protected PropertyChangeListener

Returns:

a property change listener
createPropertyChangeListener
()

Creates a property change listener.

protected JButton

Returns:

Widget for user to
createScrollButton
(int
One of the SwingConstants constants: SOUTH, NORTH, EAST or WEST
direction
)

Creates and returns a JButton that will provide the user with a way to scroll the tabs in a particular direction.

public static ComponentUI

Returns:

a UI
createUI
(JComponent
a component
c
)

Hides javax.swing.plaf.ComponentUI.createUI.

Creates a UI.

private void
protected void
expandTabRunsArray()

Expands the tab runs array.

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

Overrides javax.swing.plaf.ComponentUI.getBaseline.

Returns the baseline.

protected int

Returns:

baseline or a value < 0 indicating there is no reasonable baseline
getBaseline
(int
index of tab to get baseline for
tab
)

Returns the baseline for the specified tab.

protected int

Returns:

amount to offset the baseline by
getBaselineOffset
()

Returns the amount the baseline is offset by.

public Component.BaselineResizeBehavior
getBaselineResizeBehavior(JComponent c)

Overrides javax.swing.plaf.ComponentUI.getBaselineResizeBehavior.

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

private int
getClosestTab(int x, int y)

Returns the index of the tab closest to the passed in location, note that the returned tab may not contain the location x,y.

protected Insets

Returns:

the content border insets
getContentBorderInsets
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
)

Returns the content border insets.

protected int

Returns:

index of tab that has focus
getFocusIndex
()

Returns the index of the tab that has focus.

protected FontMetrics

Returns:

the font metrics
getFontMetrics
()

Returns the font metrics.

private BasicTabbedPaneUI.Handler
protected Icon

Returns:

the icon for a tab
getIconForTab
(int
the index of the tab
tabIndex
)

Returns the icon for a tab.

pack-priv InputMap
getInputMap(int condition)

public Dimension
getMaximumSize(JComponent c)

Overrides javax.swing.plaf.ComponentUI.getMaximumSize.

Returns the specified component's maximum size appropriate for the look and feel.

public Dimension
getMinimumSize(JComponent c)

Overrides javax.swing.plaf.ComponentUI.getMinimumSize.

Returns the specified component's minimum size appropriate for the look and feel.

protected int

Returns:

the next tab index
getNextTabIndex
(int
the base
base
)

Returns the next tab index.

protected int

Returns:

the next tab index in the run
getNextTabIndexInRun
(int
the tab count
tabCount
,
int
the base
base
)

Returns the next tab index in the run.

protected int

Returns:

the next tab run
getNextTabRun
(int
the base run
baseRun
)

Returns the next tab run.

protected int

Returns:

the previous tab index
getPreviousTabIndex
(int
the base
base
)

Returns the previous tab index.

protected int

Returns:

the previous tab index in the run
getPreviousTabIndexInRun
(int
the tab count
tabCount
,
int
the base
base
)

Returns the previous tab index in the run.

protected int

Returns:

the previous tab run
getPreviousTabRun
(int
the base run
baseRun
)

Returns the previous tab run.

protected int

Returns:

the tab the mouse is currently over, or -1 if the mouse is no longer over any tab
getRolloverTab
()

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

protected int

Returns:

the run for a tab
getRunForTab
(int
the tab count
tabCount
,
int
the tab index.
tabIndex
)

Returns the run for a tab.

protected Insets

Returns:

the selected tab pad insets
getSelectedTabPadInsets
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
)

Returns the selected tab pad insets.

protected Insets

Returns:

the pad area insets
getTabAreaInsets
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
)

Returns the tab area insets.

public Rectangle
getTabBounds(JTabbedPane pane, int i)

Implements abstract javax.swing.plaf.TabbedPaneUI.getTabBounds.

Returns the bounds of the specified tab index.

protected Rectangle

Returns:

the resulting rectangle
getTabBounds
(int
the index of the tab
tabIndex
,
Rectangle
the rectangle where the result should be placed
dest
)

Returns the bounds of the specified tab in the coordinate space of the JTabbedPane component.

protected Insets

Returns:

the tab insets
getTabInsets
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the tab index
tabIndex
)

Returns the tab insets.

protected int

Returns:

the tab label shift x
getTabLabelShiftX
(int
the tab placement
tabPlacement
,
int
the tab index
tabIndex
,
boolean
selection status
isSelected
)

Returns the tab label shift x.

protected int

Returns:

the tab label shift y
getTabLabelShiftY
(int
the tab placement
tabPlacement
,
int
the tab index
tabIndex
,
boolean
selection status
isSelected
)

Returns the tab label shift y.

public int
getTabRunCount(JTabbedPane pane)

Implements abstract javax.swing.plaf.TabbedPaneUI.getTabRunCount.

Returns the tab run count.

protected int

Returns:

the tab run indent
getTabRunIndent
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the tab run
run
)

Returns the tab run indent.

protected int

Returns:

the tab run offset
getTabRunOffset
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the tab count
tabCount
,
int
the index of the tab with respect to other tabs
tabIndex
,
boolean
forward or not
forward
)

Returns the tab run offset.

protected int

Returns:

the tab run overlay
getTabRunOverlay
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
)

Returns the tab run overlay.

protected View

Returns:

the text view to render the tab's text or null if no specialized rendering is required
getTextViewForTab
(int
the index of the tab
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.

protected Component

Returns:

the visible component
getVisibleComponent
()

Returns the visible component.

private void
initMnemonics()

Installs the state needed for mnemonics.

protected void
installComponents()

Creates and installs any required subcomponents for the JTabbedPane.

protected void
installDefaults()

Installs the defaults.

protected void
installKeyboardActions()

Installs the keyboard actions.

protected void
installListeners()

Installs the listeners.

private void
public void
installUI(JComponent c)

Overrides javax.swing.plaf.ComponentUI.installUI.

Configures the specified component appropriately for the look and feel.

private boolean
protected int

Returns:

the last tab in a run
lastTabInRun
(int
the tab count
tabCount
,
int
the run
run
)

Returns the last tab in a run.

protected void
layoutLabel(int
the tab placement
tabPlacement
,
FontMetrics
the font metrics
metrics
,
int
the tab index
tabIndex
,
String
the title
title
,
Icon
the icon
icon
,
Rectangle
the tab rectangle
tabRect
,
Rectangle
the icon rectangle
iconRect
,
Rectangle
the text rectangle
textRect
,
boolean
selection status
isSelected
)

Lays out a label.

pack-priv static void
public void
paint(Graphics g, JComponent c)

Overrides javax.swing.plaf.ComponentUI.paint.

Paints the specified component appropriately for the look and feel.

protected void
paintContentBorder(Graphics
the graphics context in which to paint
g
,
int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the tab index of the selected component
selectedIndex
)

Paints the content border.

protected void
paintContentBorderBottomEdge(Graphics
the graphics context in which to paint
g
,
int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the tab index of the selected component
selectedIndex
,
int
the x coordinate of tab
x
,
int
the y coordinate of tab
y
,
int
the width of the tab
w
,
int
the height of the tab
h
)

Paints the content border bottom edge.

protected void
paintContentBorderLeftEdge(Graphics
the graphics context in which to paint
g
,
int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the tab index of the selected component
selectedIndex
,
int
the x coordinate of tab
x
,
int
the y coordinate of tab
y
,
int
the width of the tab
w
,
int
the height of the tab
h
)

Paints the content border left edge.

protected void
paintContentBorderRightEdge(Graphics
the graphics context in which to paint
g
,
int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the tab index of the selected component
selectedIndex
,
int
the x coordinate of tab
x
,
int
the y coordinate of tab
y
,
int
the width of the tab
w
,
int
the height of the tab
h
)

Paints the content border right edge.

protected void
paintContentBorderTopEdge(Graphics
the graphics context in which to paint
g
,
int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the tab index of the selected component
selectedIndex
,
int
the x coordinate of tab
x
,
int
the y coordinate of tab
y
,
int
the width of the tab
w
,
int
the height of the tab
h
)

Paints the content border top edge.

private void
protected void
paintFocusIndicator(Graphics
the graphics
g
,
int
the tab placement
tabPlacement
,
Rectangle[]
the tab rectangles
rects
,
int
the tab index
tabIndex
,
Rectangle
the icon rectangle
iconRect
,
Rectangle
the text rectangle
textRect
,
boolean
selection status
isSelected
)

Paints the focus indicator.

protected void
paintIcon(Graphics
the graphics
g
,
int
the tab placement
tabPlacement
,
int
the tab index
tabIndex
,
Icon
the icon
icon
,
Rectangle
the icon rectangle
iconRect
,
boolean
selection status
isSelected
)

Paints an icon.

protected void
paintTab(Graphics
the graphics
g
,
int
the tab placement
tabPlacement
,
Rectangle[]
the tab rectangles
rects
,
int
the tab index
tabIndex
,
Rectangle
the icon rectangle
iconRect
,
Rectangle
the text rectangle
textRect
)

Paints a tab.

protected void
paintTabArea(Graphics
the graphics object to use for rendering
g
,
int
the placement for the tabs within the JTabbedPane
tabPlacement
,
int
the tab index of the selected component
selectedIndex
)

Paints the tabs in the tab area.

protected void
paintTabBackground(Graphics
the graphics context in which to paint
g
,
int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the index of the tab with respect to other tabs
tabIndex
,
int
the x coordinate of tab
x
,
int
the y coordinate of tab
y
,
int
the width of the tab
w
,
int
the height of the tab
h
,
boolean
a boolean which determines whether or not the tab is selected
isSelected
)

Paints the tab background.

protected void
paintTabBorder(Graphics
the graphics context in which to paint
g
,
int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the index of the tab with respect to other tabs
tabIndex
,
int
the x coordinate of tab
x
,
int
the y coordinate of tab
y
,
int
the width of the tab
w
,
int
the height of the tab
h
,
boolean
a boolean which determines whether or not the tab is selected
isSelected
)

Paints the border around a tab.

protected void
paintText(Graphics
the graphics
g
,
int
the tab placement
tabPlacement
,
Font
the font
font
,
FontMetrics
the font metrics
metrics
,
int
the tab index
tabIndex
,
String
the title
title
,
Rectangle
the text rectangle
textRect
,
boolean
selection status
isSelected
)

Paints text.

private void
repaintTab(int index)

Repaints the specified tab.

pack-priv boolean
private void
resetMnemonics()

Resets the mnemonics bindings to an empty state.

protected static void
rotateInsets(Insets
the top insets
topInsets
,
Insets
the target insets
targetInsets
,
int
the target placement
targetPlacement
)

Rotates the insets.

private boolean
protected void
selectAdjacentRunTab(int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the index of the tab with respect to other tabs
tabIndex
,
int
selection offset
offset
)

Selects an adjacent run of tabs.

protected void
selectNextTab(int
the current tab
current
)

Selects the next tab.

protected void
selectNextTabInRun(int
the current tab
current
)

Selects the next tab in the run.

protected void
selectPreviousTab(int
the current tab
current
)

Selects the previous tab.

protected void
selectPreviousTabInRun(int
the current tab
current
)

Selects the previous tab in the run.

pack-priv void
setFocusIndex(int index, boolean repaint)

private void
setRolloverTab(int x, int y)

Sets the tab the mouse is over by location.

protected void
setRolloverTab(int
Index of the tab the mouse is over.
index
)

Sets the tab the mouse is currently over to index.

protected void
setVisibleComponent(Component
the component
component
)

Sets the visible component.

protected boolean

Returns:

whether or not the tab run should be padded
shouldPadTabRun
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
,
int
the tab run
run
)

Returns whether or not the tab run should be padded.

protected boolean

Returns:

whether or not the tab run should be rotated
shouldRotateTabRuns
(int
the placement (left, right, bottom, top) of the tab
tabPlacement
)

Returns whether or not the tab run should be rotated.

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

Implements abstract javax.swing.plaf.TabbedPaneUI.tabForCoordinate.

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

private int
tabForCoordinate(JTabbedPane pane, int x, int y, boolean validateIfNecessary)

private Point
translatePointToTabPanel(int srcx, int srcy, Point dest)

Returns a point which is translated from the specified point in the JTabbedPane's coordinate space to the coordinate space of the ScrollableTabPanel.

protected void
uninstallComponents()

Removes any installed subcomponents from the JTabbedPane.

protected void
uninstallDefaults()

Uninstalls the defaults.

protected void
uninstallKeyboardActions()

Uninstalls the keyboard actions.

protected void
uninstallListeners()

Uninstalls the listeners.

private void
public void
uninstallUI(JComponent c)

Overrides javax.swing.plaf.ComponentUI.uninstallUI.

Reverses configuration which was done on the specified component during installUI.

private void
updateMnemonics()

Reloads the mnemonics.

private void
validateFocusIndex()

Makes sure the focusIndex is valid.