com.jgoodies.looks.plastic

Class PlasticTabbedPaneUI

public final class PlasticTabbedPaneUI extends MetalTabbedPaneUI

The JGoodies Plastic Look&Feel implementation of TabbedPaneUI. It differs from its superclass MetalTabbedPaneUI in that it paints new tab shapes, provides two options, and supports ClearLook.

You can enable or disable icons in tabs globally via com.jgoodies.looks.Options.setTabIconsEnabled(boolean).

To disable the content border set

 JTabbedPane tabbedPane = new JTabbedPane();
 tabbedPane.putClientProperty(Option.NO_CONTENT_BORDER_KEY, Boolean.TRUE);
 
To paint embedded tabs use
 JTabbedPane tabbedPane = new JTabbedPane();
 tabbedPane.putClientProperty(Option.EMBEDDED_TABS_KEY, Boolean.TRUE);
 

There's a special mode that helps you detect content borders in heavily wrapped component hierarchies - such as the NetBeans IDE. In this marked mode the content border is painted as a Magenta line. You can enable this mode by setting the System property markContentBorders to true; in a command line:

 java -DmarkContentBorders=true
 

Version: $Revision: 1.10 $

Author: Karsten Lentzsch Torge Husfeldt Andrej Golovnin

See Also: Options

Method Summary
protected ChangeListenercreateChangeListener()
protected LayoutManagercreateLayoutManager()
Creates the layout manager used to set the tab's bounds.
protected PropertyChangeListenercreatePropertyChangeListener()
Creates and answer a handler that listens to property changes.
static ComponentUIcreateUI(JComponent tabPane)
Creates the PlasticTabbedPaneUI.
protected InsetsgetContentBorderInsets(int tabPlacement)
Returns the insets (i.e. the width) of the content Border.
protected IcongetIconForTab(int tabIndex)
Answers the icon for the tab with the specified index.
protected InsetsgetSelectedTabPadInsets(int tabPlacement)
Returns the insets for selected tab.
protected InsetsgetTabAreaInsets(int tabPlacement)
Returns the amount by which the Tab Area is inset.
protected RectanglegetTabBounds(int tabIndex, Rectangle dest)
protected InsetsgetTabInsets(int tabPlacement, int tabIndex)
Returns the insets for this tab.
protected intgetTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected)
Returns the amount by which the label should be shifted horizontally.
protected intgetTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected)
Returns the amount by which the label should be shifted vertically.
protected intgetTabRunIndent(int tabPlacement, int run)
Returns the amount by which the run number run should be indented.
protected intgetTabRunOverlay(int tabPlacement)
Returns the amount (in pixels) by which two runs should overlap.
protected voidinstallComponents()
Creates and installs any required subcomponents for the JTabbedPane.
protected voidinstallKeyboardActions()
protected voidinstallListeners()
voidinstallUI(JComponent c)
Installs the UI.
protected booleanisTabInFirstRun(int tabIndex)
protected voidlayoutLabel(int tabPlacement, FontMetrics metrics, int tabIndex, String title, Icon icon, Rectangle tabRect, Rectangle iconRect, Rectangle textRect, boolean isSelected)
voidpaint(Graphics g, JComponent c)
protected voidpaintContentBorder(Graphics g, int tabPlacement, int selectedIndex)
protected voidpaintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rectangles, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected)
Draws the rectancle around the Tab label which indicates keyboard focus.
protected voidpaintTab(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect)
protected voidpaintTabArea(Graphics g, int tabPlacement, int selectedIndex)
protected voidpaintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
Fills the background of the given tab to make sure overlap of tabs is handled correctly.
protected voidpaintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
Paints the border for one tab.
protected booleanshouldPadTabRun(int tabPlacement, int run)
This boolean controls wheather the given run should be padded to use up as much space as the others (with more tabs in them).
protected booleanshouldRotateTabRuns(int tabPlacement)
Answers wheather tab runs should be rotated.
inttabForCoordinate(JTabbedPane pane, int x, int y)
Returns the tab index which intersects the specified point in the JTabbedPane's coordinate space.
protected voiduninstallComponents()
Removes any installed subcomponents from the JTabbedPane.
protected voiduninstallListeners()
voiduninstallUI(JComponent c)
Uninstalls the UI.

Method Detail

createChangeListener

protected ChangeListener createChangeListener()

createLayoutManager

protected LayoutManager createLayoutManager()
Creates the layout manager used to set the tab's bounds.

createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener()
Creates and answer a handler that listens to property changes. Unlike the superclass BasicTabbedPane, the PlasticTabbedPaneUI uses an extended Handler.

createUI

public static ComponentUI createUI(JComponent tabPane)
Creates the PlasticTabbedPaneUI.

See Also: javax.swing.plaf.ComponentUI#createUI(JComponent)

getContentBorderInsets

protected Insets getContentBorderInsets(int tabPlacement)
Returns the insets (i.e. the width) of the content Border.

getIconForTab

protected Icon getIconForTab(int tabIndex)
Answers the icon for the tab with the specified index. In case, we have globally switched of the use tab icons, we answer null if and only if we have a title.

getSelectedTabPadInsets

protected Insets getSelectedTabPadInsets(int tabPlacement)
Returns the insets for selected tab.

getTabAreaInsets

protected Insets getTabAreaInsets(int tabPlacement)
Returns the amount by which the Tab Area is inset.

getTabBounds

protected Rectangle getTabBounds(int tabIndex, Rectangle dest)

getTabInsets

protected Insets getTabInsets(int tabPlacement, int tabIndex)
Returns the insets for this tab.

getTabLabelShiftX

protected int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected)
Returns the amount by which the label should be shifted horizontally.

getTabLabelShiftY

protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected)
Returns the amount by which the label should be shifted vertically.

getTabRunIndent

protected int getTabRunIndent(int tabPlacement, int run)
Returns the amount by which the run number run should be indented. Add six pixels for every run to make diagonal lines align.

getTabRunOverlay

protected int getTabRunOverlay(int tabPlacement)
Returns the amount (in pixels) by which two runs should overlap.

installComponents

protected void installComponents()
Creates and installs any required subcomponents for the JTabbedPane. Invoked by installUI.

See Also: javax.swing.plaf.basic.BasicTabbedPaneUI#installComponents()

installKeyboardActions

protected void installKeyboardActions()

installListeners

protected void installListeners()

installUI

public void installUI(JComponent c)
Installs the UI.

See Also: javax.swing.plaf.ComponentUI#installUI(JComponent)

isTabInFirstRun

protected boolean isTabInFirstRun(int tabIndex)

layoutLabel

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

paint

public void paint(Graphics g, JComponent c)

paintContentBorder

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

paintFocusIndicator

protected void paintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rectangles, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected)
Draws the rectancle around the Tab label which indicates keyboard focus.

paintTab

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

paintTabArea

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

paintTabBackground

protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
Fills the background of the given tab to make sure overlap of tabs is handled correctly. Note: that tab backgrounds seem to be painted somewhere else, too.

paintTabBorder

protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
Paints the border for one tab. Gets the bounds of the tab as parameters. Note that the result is not clipped so you can paint outside that rectangle. Tabs painted later on have a chance to overwrite though.

shouldPadTabRun

protected boolean shouldPadTabRun(int tabPlacement, int run)
This boolean controls wheather the given run should be padded to use up as much space as the others (with more tabs in them).

shouldRotateTabRuns

protected boolean shouldRotateTabRuns(int tabPlacement)
Answers wheather tab runs should be rotated. If true, the layout mechanism will move the run containing the selected tab so that it touches the content pane.

tabForCoordinate

public int tabForCoordinate(JTabbedPane pane, int x, int y)
Returns the tab index which intersects the specified point in the JTabbedPane's coordinate space.

uninstallComponents

protected void uninstallComponents()
Removes any installed subcomponents from the JTabbedPane. Invoked by uninstallUI.

See Also: javax.swing.plaf.basic.BasicTabbedPaneUI#uninstallComponents()

uninstallListeners

protected void uninstallListeners()

uninstallUI

public void uninstallUI(JComponent c)
Uninstalls the UI.

See Also: javax.swing.plaf.ComponentUI#uninstallUI(JComponent)

Copyright © 2001-2008 JGoodies Karsten Lentzsch. All Rights Reserved.