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

public Class SynthTabbedPaneUI

extends BasicTabbedPaneUI
implements PropertyChangeListener, SynthUI
Class Inheritance
All Implemented Interfaces
javax.swing.plaf.synth.SynthUI, javax.swing.plaf.synth.SynthConstants, java.beans.PropertyChangeListener, java.util.EventListener
Imports
java.awt.Component, .Font, .FontMetrics, .Graphics, .Insets, .LayoutManager, .Rectangle, java.awt.event.MouseEvent, .MouseListener, .MouseMotionListener, java.beans.PropertyChangeEvent, .PropertyChangeListener, javax.swing.BorderFactory, .Icon, .JButton, .JComponent, .JTabbedPane, .SwingUtilities, .UIManager, javax.swing.plaf.ComponentUI, .UIResource, javax.swing.plaf.basic.BasicTabbedPaneUI, javax.swing.text.View, sun.swing.SwingUtilities2

Provides the Synth L&F UI delegate for javax.swing.JTabbedPane.

Looks up the selectedTabPadInsets property from the Style, which represents additional insets for the selected tab.

Author
Scott Violet
Since
1.7

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
SynthTabbedPaneUI.SynthScrollableTabButton

A subclass of SynthArrowButton that implements UIResource.

Field Summary

Modifier and TypeField and Description
private boolean
extendTabsToBase

When a tabbed pane has multiple rows of tabs, this indicates whether the tabs in the upper row(s) should extend to the base of the tab area, or whether they should remain at their normal tab height.

private Rectangle
private boolean
private boolean
private SynthStyle
private Rectangle
private SynthContext
private boolean
private SynthStyle
private SynthContext
private SynthStyle
private SynthContext
private int
tabOverlap

If non-zero, tabOverlap indicates the amount that the tab bounds should be altered such that they would overlap with a tab on either the leading or trailing end of a run (ie: in TOP, this would be on the left or right).

private SynthStyle
private Rectangle
Inherited from javax.swing.plaf.basic.BasicTabbedPaneUI:
calcRectcontentBorderInsetsdarkShadowdownKeyfocusfocusListenerhighlightleftKeylightHighlightmaxTabHeightmaxTabWidthmouseListenerpropertyChangeListenerrectsrightKeyrunCountselectedRunselectedTabPadInsetsshadowtabAreaInsetstabChangeListenertabInsetstabPanetabRunOverlaytabRunstextIconGapupKey

Constructor Summary

AccessConstructor and Description
public
SynthTabbedPaneUI()

Constructs a SynthTabbedPaneUI.

Method Summary

Modifier and TypeMethod and Description
protected int
calculateMaxTabHeight(int tabPlacement)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.calculateMaxTabHeight.

Calculates the maximum tab height.

protected int
calculateMaxTabWidth(int tabPlacement)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.calculateMaxTabWidth.

Calculates the maximum tab width.

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

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.calculateTabWidth.

Calculates the tab width.

protected LayoutManager
createLayoutManager()

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.createLayoutManager.

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

protected MouseListener
protected JButton
createScrollButton(int direction)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.createScrollButton.

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:

the UI object
createUI
(JComponent
component to create UI object for
c
)

Hides javax.swing.plaf.basic.BasicTabbedPaneUI.createUI.

Creates a new UI object for the given component.

private void
protected int
getBaseline(int tab)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.getBaseline.

Returns the baseline for the specified tab.

public SynthContext
getContext(JComponent c)

Implements javax.swing.plaf.synth.SynthUI.getContext.

Returns the Context for the specified component.

private SynthContext
getContext(JComponent c, int state)

private SynthContext
getContext(JComponent c, Region subregion, int state)

protected FontMetrics
private FontMetrics
protected Insets
getTabInsets(int tabPlacement, int tabIndex)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.getTabInsets.

Returns the tab insets.

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

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.getTabLabelShiftX.

Returns the tab label shift x.

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

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.getTabLabelShiftY.

Returns the tab label shift y.

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

public void
paint(Graphics
the Graphics object used for painting
g
,
JComponent
the component being painted
c
)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.paint.

Paints the specified component according to the Look and Feel.

protected void
paint(SynthContext
context for the component being painted
context
,
Graphics
the Graphics object used for painting
g
)

Paints the specified component.

public void
paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)

Implements javax.swing.plaf.synth.SynthUI.paintBorder.

Paints the border.

private void
paintContentBorder(SynthContext ss, Graphics g, int tabPlacement, int selectedIndex)

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

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

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea.

Paints the tabs in the tab area.

private void
paintTabArea(SynthContext ss, Graphics g, int tabPlacement, int selectedIndex, Rectangle tabAreaBounds)

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

public void
propertyChange(PropertyChangeEvent e)

Implements java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

private boolean
protected void
setRolloverTab(int index)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.setRolloverTab.

Sets the tab the mouse is currently over to index.

protected void
protected void
public void
update(Graphics
the Graphics object used for painting
g
,
JComponent
the component being painted
c
)

Overrides javax.swing.plaf.ComponentUI.update.

Notifies this UI delegate to repaint the specified component.

private void
private void
updateTabContext(int index, boolean selected, boolean isMouseDown, boolean isMouseOver, boolean hasFocus)

Inherited from javax.swing.plaf.basic.BasicTabbedPaneUI:
assureRectsCreatedcalculateTabAreaHeightcalculateTabAreaWidthcalculateTabHeightcreateChangeListenercreateFocusListenercreatePropertyChangeListenerexpandTabRunsArraygetBaselinegetBaselineOffsetgetBaselineResizeBehaviorgetContentBorderInsetsgetFocusIndexgetIconForTabgetMaximumSizegetMinimumSizegetNextTabIndexgetNextTabIndexInRungetNextTabRungetPreviousTabIndexgetPreviousTabIndexInRungetPreviousTabRungetRolloverTabgetRunForTabgetSelectedTabPadInsetsgetTabAreaInsetsgetTabBoundsgetTabBoundsgetTabRunCountgetTabRunIndentgetTabRunOffsetgetTabRunOverlaygetTextViewForTabgetVisibleComponentinstallComponentsinstallKeyboardActionsinstallUIlastTabInRunlayoutLabelnavigateSelectedTabpaintContentBorderpaintContentBorderBottomEdgepaintContentBorderLeftEdgepaintContentBorderRightEdgepaintContentBorderTopEdgepaintFocusIndicatorpaintIconpaintTabpaintTabBackgroundpaintTabBorderpaintTextrotateInsetsselectAdjacentRunTabselectNextTabselectNextTabInRunselectPreviousTabselectPreviousTabInRunsetVisibleComponentshouldPadTabRunshouldRotateTabRunstabForCoordinateuninstallComponentsuninstallKeyboardActionsuninstallUI

Field Detail

extendTabsToBaseback to summary
private boolean extendTabsToBase

When a tabbed pane has multiple rows of tabs, this indicates whether the tabs in the upper row(s) should extend to the base of the tab area, or whether they should remain at their normal tab height. This does not affect the bounds of the tabs, only the bounds of area painted by the tabs. The text position does not change. The result is that the bottom border of the upper row of tabs becomes fully obscured by the lower tabs, resulting in a cleaner look.

iconRectback to summary
private Rectangle iconRect
nudgeSelectedLabelback to summary
private boolean nudgeSelectedLabel
selectedTabIsPressedback to summary
private boolean selectedTabIsPressed
styleback to summary
private SynthStyle style
tabAreaBoundsback to summary
private Rectangle tabAreaBounds
tabAreaContextback to summary
private SynthContext tabAreaContext
tabAreaStatesMatchSelectedTabback to summary
private boolean tabAreaStatesMatchSelectedTab
tabAreaStyleback to summary
private SynthStyle tabAreaStyle
tabContentContextback to summary
private SynthContext tabContentContext
tabContentStyleback to summary
private SynthStyle tabContentStyle
tabContextback to summary
private SynthContext tabContext
tabOverlapback to summary
private int tabOverlap

If non-zero, tabOverlap indicates the amount that the tab bounds should be altered such that they would overlap with a tab on either the leading or trailing end of a run (ie: in TOP, this would be on the left or right).

A positive overlap indicates that tabs should overlap right/down, while a negative overlap indicates that tabs should overlap left/up.

When tabOverlap is specified, it both changes the x position and width of the tab if in TOP or BOTTOM placement, and changes the y position and height if in LEFT or RIGHT placement.

This is done for the following reason. Consider a run of 10 tabs. There are 9 gaps between these tabs. If you specified a tabOverlap of "-1", then each of the tabs "x" values will be shifted left. This leaves 9 pixels of space to the right of the right-most tab unpainted. So, each tab's width is also extended by 1 pixel to make up the difference.

This property respects the RTL component orientation.

tabStyleback to summary
private SynthStyle tabStyle
textRectback to summary
private Rectangle textRect

Constructor Detail

SynthTabbedPaneUIback to summary
public SynthTabbedPaneUI()

Constructs a SynthTabbedPaneUI.

Method Detail

calculateMaxTabHeightback to summary
protected int calculateMaxTabHeight(int tabPlacement)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.calculateMaxTabHeight.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.calculateMaxTabHeight.

Calculates the maximum tab height.

Annotations
@Override
calculateMaxTabWidthback to summary
protected int calculateMaxTabWidth(int tabPlacement)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.calculateMaxTabWidth.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.calculateMaxTabWidth.

Calculates the maximum tab width.

Annotations
@Override
calculateTabWidthback to summary
protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.calculateTabWidth.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.calculateTabWidth.

Calculates the tab width.

Annotations
@Override
createLayoutManagerback to summary
protected LayoutManager createLayoutManager()

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.createLayoutManager.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.createLayoutManager.

Invoked by installUI to create a layout manager object to manage the JTabbedPane. Overridden to create a TabbedPaneLayout subclass which takes into account tabOverlap.

Annotations
@Override
createMouseListenerback to summary
protected MouseListener createMouseListener()

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.createMouseListener.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.createMouseListener.

Creates a mouse listener. Overridden to keep track of whether the selected tab is also pressed.

Annotations
@Override
createScrollButtonback to summary
protected JButton createScrollButton(int direction)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.createScrollButton.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.createScrollButton.

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.

Annotations
@Override
createUIback to summary
public static ComponentUI createUI(JComponent c)

Hides javax.swing.plaf.basic.BasicTabbedPaneUI.createUI.

Creates a new UI object for the given component.

Parameters
c:JComponent

component to create UI object for

Returns:ComponentUI

the UI object

ensureCurrentLayoutback to summary
private void ensureCurrentLayout()

Hides javax.swing.plaf.basic.BasicTabbedPaneUI.ensureCurrentLayout.

getBaselineback to summary
protected int getBaseline(int tab)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.getBaseline.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.getBaseline.

Returns the baseline for the specified tab.

Annotations
@Override
getContextback to summary
public SynthContext getContext(JComponent c)

Implements javax.swing.plaf.synth.SynthUI.getContext.

Doc from javax.swing.plaf.synth.SynthUI.getContext.

Returns the Context for the specified component.

Annotations
@Override
getContextback to summary
private SynthContext getContext(JComponent c, int state)
getContextback to summary
private SynthContext getContext(JComponent c, Region subregion, int state)
getFontMetricsback to summary
protected FontMetrics getFontMetrics()

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.getFontMetrics.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.getFontMetrics.

Returns the font metrics.

Annotations
@Override
getFontMetricsback to summary
private FontMetrics getFontMetrics(Font font)
getTabInsetsback to summary
protected Insets getTabInsets(int tabPlacement, int tabIndex)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.getTabInsets.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.getTabInsets.

Returns the tab insets.

Annotations
@Override
getTabLabelShiftXback to summary
protected int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.getTabLabelShiftX.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.getTabLabelShiftX.

Returns the tab label shift x.

Annotations
@Override
getTabLabelShiftYback to summary
protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.getTabLabelShiftY.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.getTabLabelShiftY.

Returns the tab label shift y.

Annotations
@Override
installDefaultsback to summary
protected void installDefaults()

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.installDefaults.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.installDefaults.

Installs the defaults.

Annotations
@Override
installListenersback to summary
protected void installListeners()

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.installListeners.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.installListeners.

Installs the listeners.

Annotations
@Override
layoutLabelback to summary
private void layoutLabel(SynthContext ss, int tabPlacement, FontMetrics metrics, int tabIndex, String title, Icon icon, Rectangle tabRect, Rectangle iconRect, Rectangle textRect, boolean isSelected)
paintback to summary
public void paint(Graphics g, JComponent c)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.paint.

Paints the specified component according to the Look and Feel.

This method is not used by Synth Look and Feel. Painting is handled by the paint(SynthContext, Graphics) method.

Parameters
g:Graphics

the Graphics object used for painting

c:JComponent

the component being painted

Annotations
@Override
See Also
paint(SynthContext, Graphics)
paintback to summary
protected void paint(SynthContext context, Graphics g)

Paints the specified component.

Parameters
context:SynthContext

context for the component being painted

g:Graphics

the Graphics object used for painting

See Also
update(Graphics, JComponent)
paintBorderback to summary
public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)

Implements javax.swing.plaf.synth.SynthUI.paintBorder.

Doc from javax.swing.plaf.synth.SynthUI.paintBorder.

Paints the border.

Annotations
@Override
paintContentBorderback to summary
private void paintContentBorder(SynthContext ss, Graphics g, int tabPlacement, int selectedIndex)
paintTabback to summary
private void paintTab(SynthContext ss, Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect)
paintTabAreaback to summary
protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea.

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.

paintTabAreaback to summary
private void paintTabArea(SynthContext ss, Graphics g, int tabPlacement, int selectedIndex, Rectangle tabAreaBounds)
paintTextback to summary
private void paintText(SynthContext ss, Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected)
propertyChangeback to summary
public void propertyChange(PropertyChangeEvent e)

Implements java.beans.PropertyChangeListener.propertyChange.

Doc from java.beans.PropertyChangeListener.propertyChange.

This method gets called when a bound property is changed.

Annotations
@Override
scrollableTabLayoutEnabledback to summary
private boolean scrollableTabLayoutEnabled()

Hides javax.swing.plaf.basic.BasicTabbedPaneUI.scrollableTabLayoutEnabled.

setRolloverTabback to summary
protected void setRolloverTab(int index)

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.setRolloverTab.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.setRolloverTab.

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.

Annotations
@Override
uninstallDefaultsback to summary
protected void uninstallDefaults()

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.uninstallDefaults.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.uninstallDefaults.

Uninstalls the defaults.

Annotations
@Override
uninstallListenersback to summary
protected void uninstallListeners()

Overrides javax.swing.plaf.basic.BasicTabbedPaneUI.uninstallListeners.

Doc from javax.swing.plaf.basic.BasicTabbedPaneUI.uninstallListeners.

Uninstalls the listeners.

Annotations
@Override
updateback to summary
public void update(Graphics g, JComponent c)

Overrides javax.swing.plaf.ComponentUI.update.

Notifies this UI delegate to repaint the specified component. This method paints the component background, then calls the paint(SynthContext, Graphics) method.

In general, this method does not need to be overridden by subclasses. All Look and Feel rendering code should reside in the paint method.

Parameters
g:Graphics

the Graphics object used for painting

c:JComponent

the component being painted

Annotations
@Override
See Also
paint(SynthContext, Graphics)
updateStyleback to summary
private void updateStyle(JTabbedPane c)
updateTabContextback to summary
private void updateTabContext(int index, boolean selected, boolean isMouseDown, boolean isMouseOver, boolean hasFocus)
javax.swing.plaf.synth back to summary

private Class SynthTabbedPaneUI.SynthScrollableTabButton

extends SynthArrowButton
implements UIResource
Class Inheritance
All Implemented Interfaces
javax.swing.plaf.UIResource
Annotations
@SuppressWarnings:serial

A subclass of SynthArrowButton that implements UIResource.

Constructor Summary

AccessConstructor and Description
public
SynthScrollableTabButton(int direction)

Method Summary

Inherited from javax.swing.plaf.synth.SynthArrowButton:
getDirectiongetUIClassIDsetDirectionsetFocusableupdateUI

Constructor Detail

SynthScrollableTabButtonback to summary
public SynthScrollableTabButton(int direction)