Class MetalTabbedPaneUI
java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.TabbedPaneUI
javax.swing.plaf.basic.BasicTabbedPaneUI
javax.swing.plaf.metal.MetalTabbedPaneUI
- All Implemented Interfaces:
SwingConstants
The Metal subclass of BasicTabbedPaneUI.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see XMLEncoder.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassThis class should be treated as a "protected" inner class.Nested classes/interfaces inherited from class javax.swing.plaf.basic.BasicTabbedPaneUI
BasicTabbedPaneUI.FocusHandler, BasicTabbedPaneUI.MouseHandler, BasicTabbedPaneUI.PropertyChangeHandler, BasicTabbedPaneUI.TabSelectionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe minimum width of a pane.protected ColorThe color of the selected pane.protected ColorThe color of the highlight.protected ColorThe color of tab's background.Fields inherited from class javax.swing.plaf.basic.BasicTabbedPaneUI
calcRect, contentBorderInsets, darkShadow, downKey, focus, focusListener, highlight, leftKey, lightHighlight, maxTabHeight, maxTabWidth, mouseListener, propertyChangeListener, rects, rightKey, runCount, selectedRun, selectedTabPadInsets, shadow, tabAreaInsets, tabChangeListener, tabInsets, tabPane, tabRunOverlay, tabRuns, textIconGap, upKeyFields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intcalculateMaxTabHeight(int tabPlacement) Calculates the maximum tab height.protected LayoutManagerInvoked byinstallUIto create a layout manager object to manage theJTabbedPane.static ComponentUIConstructsMetalTabbedPaneUI.protected intReturns the amount the baseline is offset by.protected ColorgetColorForGap(int currentRun, int x, int y) Returns the color of the gap.protected intgetTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected) Overridden to do nothing for the Java L&F.protected intgetTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected) Overridden to do nothing for the Java L&F.protected intgetTabRunOverlay(int tabPlacement) Returns the tab run overlay.protected voidInstalls the defaults.voidpaint(Graphics g, JComponent c) Paints the specified component appropriately for the look and feel.protected voidpaintBottomTabBorder(int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, boolean isSelected) Paints the bottom tab border.protected voidpaintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) Paints the content border bottom edge.protected voidpaintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) Paints the content border left edge.protected voidpaintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) Paints the content border right edge.protected voidpaintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) Paints the content border top edge.protected voidpaintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected) Paints the focus indicator.protected voidPaints highlights below tab.protected voidpaintLeftTabBorder(int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, boolean isSelected) Paints the left tab border.protected voidpaintRightTabBorder(int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, boolean isSelected) Paints the right tab border.protected voidpaintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) Paints the tab background.protected voidpaintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) Paints the border around a tab.protected voidpaintTopTabBorder(int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, boolean isSelected) Paints the top tab border.protected booleanshouldFillGap(int currentRun, int tabIndex, int x, int y) Returnstrueif the gap should be filled.protected booleanshouldPadTabRun(int tabPlacement, int run) Returns whether or not the tab run should be padded.protected booleanshouldRotateTabRuns(int tabPlacement, int selectedRun) Returnstrueif tab runs should be rotated.voidupdate(Graphics g, JComponent c) Notifies this UI delegate that it is time to paint the specified component.Methods inherited from class javax.swing.plaf.basic.BasicTabbedPaneUI
assureRectsCreated, calculateMaxTabWidth, calculateTabAreaHeight, calculateTabAreaWidth, calculateTabHeight, calculateTabWidth, createChangeListener, createFocusListener, createMouseListener, createPropertyChangeListener, createScrollButton, expandTabRunsArray, getBaseline, getBaseline, getBaselineResizeBehavior, getContentBorderInsets, getFocusIndex, getFontMetrics, getIconForTab, getMaximumSize, getMinimumSize, getNextTabIndex, getNextTabIndexInRun, getNextTabRun, getPreviousTabIndex, getPreviousTabIndexInRun, getPreviousTabRun, getRolloverTab, getRunForTab, getSelectedTabPadInsets, getTabAreaInsets, getTabBounds, getTabBounds, getTabInsets, getTabRunCount, getTabRunIndent, getTabRunOffset, getTextViewForTab, getVisibleComponent, installComponents, installKeyboardActions, installListeners, installUI, lastTabInRun, layoutLabel, navigateSelectedTab, paintContentBorder, paintIcon, paintTab, paintTabArea, paintText, rotateInsets, selectAdjacentRunTab, selectNextTab, selectNextTabInRun, selectPreviousTab, selectPreviousTabInRun, setRolloverTab, setVisibleComponent, shouldRotateTabRuns, tabForCoordinate, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners, uninstallUIMethods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getPreferredSize
-
Field Details
-
minTabWidth
protected int minTabWidthThe minimum width of a pane. -
tabAreaBackground
The color of tab's background. -
selectColor
The color of the selected pane. -
selectHighlight
The color of the highlight.
-
-
Constructor Details
-
MetalTabbedPaneUI
public MetalTabbedPaneUI()Constructs aMetalTabbedPaneUI.
-
-
Method Details
-
createUI
ConstructsMetalTabbedPaneUI.- Parameters:
x- a component- Returns:
- an instance of
MetalTabbedPaneUI
-
createLayoutManager
Description copied from class:BasicTabbedPaneUIInvoked byinstallUIto create a layout manager object to manage theJTabbedPane.- Overrides:
createLayoutManagerin classBasicTabbedPaneUI- Returns:
- a layout manager object
- See Also:
-
installDefaults
protected void installDefaults()Description copied from class:BasicTabbedPaneUIInstalls the defaults.- Overrides:
installDefaultsin classBasicTabbedPaneUI
-
paintTabBorder
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) Description copied from class:BasicTabbedPaneUIPaints the border around a tab. Note that this function does not paint the background of the tab, that is done elsewhere.- Overrides:
paintTabBorderin classBasicTabbedPaneUI- Parameters:
g- the graphics context in which to painttabPlacement- the placement (left, right, bottom, top) of the tabtabIndex- the index of the tab with respect to other tabsx- the x coordinate of taby- the y coordinate of tabw- the width of the tabh- the height of the tabisSelected- abooleanwhich determines whether or not the tab is selected
-
paintTopTabBorder
protected void paintTopTabBorder(int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, boolean isSelected) Paints the top tab border.- Parameters:
tabIndex- a tab indexg- an instance ofGraphicsx- an X coordinatey- an Y coordinatew- a widthh- a heightbtm- bottomrght- rightisSelected- a selection
-
shouldFillGap
protected boolean shouldFillGap(int currentRun, int tabIndex, int x, int y) Returnstrueif the gap should be filled.- Parameters:
currentRun- the current runtabIndex- the tab indexx- an X coordinatey- an Y coordinate- Returns:
trueif the gap should be filled
-
getColorForGap
Returns the color of the gap.- Parameters:
currentRun- the current runx- an X coordinatey- an Y coordinate- Returns:
- the color of the gap
-
paintLeftTabBorder
protected void paintLeftTabBorder(int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, boolean isSelected) Paints the left tab border.- Parameters:
tabIndex- a tab indexg- an instance ofGraphicsx- an X coordinatey- an Y coordinatew- a widthh- a heightbtm- bottomrght- rightisSelected- a selection
-
paintBottomTabBorder
protected void paintBottomTabBorder(int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, boolean isSelected) Paints the bottom tab border.- Parameters:
tabIndex- a tab indexg- an instance ofGraphicsx- an X coordinatey- an Y coordinatew- a widthh- a heightbtm- bottomrght- rightisSelected- a selection
-
paintRightTabBorder
protected void paintRightTabBorder(int tabIndex, Graphics g, int x, int y, int w, int h, int btm, int rght, boolean isSelected) Paints the right tab border.- Parameters:
tabIndex- a tab indexg- an instance ofGraphicsx- an X coordinatey- an Y coordinatew- a widthh- a heightbtm- bottomrght- rightisSelected- a selection
-
update
Description copied from class:ComponentUINotifies this UI delegate that it is time to paint the specified component. This method is invoked byJComponentwhen the specified component is being painted.By default this method fills the specified component with its background color if its
opaqueproperty istrue, and then immediately callspaint. In general this method need not be overridden by subclasses; all look-and-feel rendering code should reside in thepaintmethod.- Overrides:
updatein classComponentUI- Parameters:
g- theGraphicscontext in which to paintc- the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components- See Also:
-
paintTabBackground
protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected) Description copied from class:BasicTabbedPaneUIPaints the tab background.- Overrides:
paintTabBackgroundin classBasicTabbedPaneUI- Parameters:
g- the graphics context in which to painttabPlacement- the placement (left, right, bottom, top) of the tabtabIndex- the index of the tab with respect to other tabsx- the x coordinate of taby- the y coordinate of tabw- the width of the tabh- the height of the tabisSelected- abooleanwhich determines whether or not the tab is selected
-
getTabLabelShiftX
protected int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected) Overridden to do nothing for the Java L&F.- Overrides:
getTabLabelShiftXin classBasicTabbedPaneUI- Parameters:
tabPlacement- the tab placementtabIndex- the tab indexisSelected- selection status- Returns:
- the tab label shift x
-
getTabLabelShiftY
protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected) Overridden to do nothing for the Java L&F.- Overrides:
getTabLabelShiftYin classBasicTabbedPaneUI- Parameters:
tabPlacement- the tab placementtabIndex- the tab indexisSelected- selection status- Returns:
- the tab label shift y
-
getBaselineOffset
protected int getBaselineOffset()Returns the amount the baseline is offset by. This is typically the same asgetTabLabelShiftY.- Overrides:
getBaselineOffsetin classBasicTabbedPaneUI- Returns:
- amount to offset the baseline by
- Since:
- 1.6
-
paint
Description copied from class:ComponentUIPaints the specified component appropriately for the look and feel. This method is invoked from theComponentUI.updatemethod when the specified component is being painted. Subclasses should override this method and use the specifiedGraphicsobject to render the content of the component.- Overrides:
paintin classBasicTabbedPaneUI- Parameters:
g- theGraphicscontext in which to paintc- the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components- See Also:
-
paintHighlightBelowTab
protected void paintHighlightBelowTab()Paints highlights below tab. -
paintFocusIndicator
protected void paintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected) Description copied from class:BasicTabbedPaneUIPaints the focus indicator.- Overrides:
paintFocusIndicatorin classBasicTabbedPaneUI- Parameters:
g- the graphicstabPlacement- the tab placementrects- the tab rectanglestabIndex- the tab indexiconRect- the icon rectangletextRect- the text rectangleisSelected- selection status
-
paintContentBorderTopEdge
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) Description copied from class:BasicTabbedPaneUIPaints the content border top edge.- Overrides:
paintContentBorderTopEdgein classBasicTabbedPaneUI- Parameters:
g- the graphics context in which to painttabPlacement- the placement (left, right, bottom, top) of the tabselectedIndex- the tab index of the selected componentx- the x coordinate of taby- the y coordinate of tabw- the width of the tabh- the height of the tab
-
paintContentBorderBottomEdge
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) Description copied from class:BasicTabbedPaneUIPaints the content border bottom edge.- Overrides:
paintContentBorderBottomEdgein classBasicTabbedPaneUI- Parameters:
g- the graphics context in which to painttabPlacement- the placement (left, right, bottom, top) of the tabselectedIndex- the tab index of the selected componentx- the x coordinate of taby- the y coordinate of tabw- the width of the tabh- the height of the tab
-
paintContentBorderLeftEdge
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) Description copied from class:BasicTabbedPaneUIPaints the content border left edge.- Overrides:
paintContentBorderLeftEdgein classBasicTabbedPaneUI- Parameters:
g- the graphics context in which to painttabPlacement- the placement (left, right, bottom, top) of the tabselectedIndex- the tab index of the selected componentx- the x coordinate of taby- the y coordinate of tabw- the width of the tabh- the height of the tab
-
paintContentBorderRightEdge
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h) Description copied from class:BasicTabbedPaneUIPaints the content border right edge.- Overrides:
paintContentBorderRightEdgein classBasicTabbedPaneUI- Parameters:
g- the graphics context in which to painttabPlacement- the placement (left, right, bottom, top) of the tabselectedIndex- the tab index of the selected componentx- the x coordinate of taby- the y coordinate of tabw- the width of the tabh- the height of the tab
-
calculateMaxTabHeight
protected int calculateMaxTabHeight(int tabPlacement) Description copied from class:BasicTabbedPaneUICalculates the maximum tab height.- Overrides:
calculateMaxTabHeightin classBasicTabbedPaneUI- Parameters:
tabPlacement- the placement (left, right, bottom, top) of the tab- Returns:
- the maximum tab height
-
getTabRunOverlay
protected int getTabRunOverlay(int tabPlacement) Description copied from class:BasicTabbedPaneUIReturns the tab run overlay.- Overrides:
getTabRunOverlayin classBasicTabbedPaneUI- Parameters:
tabPlacement- the placement (left, right, bottom, top) of the tab- Returns:
- the tab run overlay
-
shouldRotateTabRuns
protected boolean shouldRotateTabRuns(int tabPlacement, int selectedRun) Returnstrueif tab runs should be rotated.- Parameters:
tabPlacement- a tab placementselectedRun- a selected run- Returns:
trueif tab runs should be rotated.
-
shouldPadTabRun
protected boolean shouldPadTabRun(int tabPlacement, int run) Description copied from class:BasicTabbedPaneUIReturns whether or not the tab run should be padded.- Overrides:
shouldPadTabRunin classBasicTabbedPaneUI- Parameters:
tabPlacement- the placement (left, right, bottom, top) of the tabrun- the tab run- Returns:
- whether or not the tab run should be padded
-