public class BasicTabbedPaneUI extends TabbedPaneUI implements SwingConstants
A Basic L&F implementation of TabbedPaneUI.
Modifier and Type | Class and Description |
---|---|
class |
BasicTabbedPaneUI.FocusHandler This class should be treated as a "protected" inner class. |
class |
BasicTabbedPaneUI.MouseHandler This class should be treated as a "protected" inner class. |
class |
BasicTabbedPaneUI.PropertyChangeHandler This class should be treated as a "protected" inner class. |
class |
BasicTabbedPaneUI.TabbedPaneLayout This class should be treated as a "protected" inner class. |
class |
BasicTabbedPaneUI.TabSelectionHandler This class should be treated as a "protected" inner class. |
protected JTabbedPane tabPane
protected Color highlight
protected Color lightHighlight
protected Color shadow
protected Color darkShadow
protected Color focus
protected int textIconGap
protected int tabRunOverlay
protected Insets tabInsets
protected Insets selectedTabPadInsets
protected Insets tabAreaInsets
protected Insets contentBorderInsets
@Deprecated 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. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
@Deprecated 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. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
@Deprecated 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. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
@Deprecated 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. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
protected int[] tabRuns
protected int runCount
protected int selectedRun
protected Rectangle[] rects
protected int maxTabHeight
protected int maxTabWidth
protected ChangeListener tabChangeListener
protected PropertyChangeListener propertyChangeListener
protected MouseListener mouseListener
protected FocusListener focusListener
protected transient Rectangle calcRect
A rectangle used for general layout calculations in order to avoid constructing many new Rectangles on the fly.
public BasicTabbedPaneUI()
public static ComponentUI createUI(JComponent c)
public void installUI(JComponent c)
Description copied from class: ComponentUI
Configures the specified component appropriately for the look and feel. This method is invoked when the ComponentUI
instance is being installed as the UI delegate on the specified component. This method should completely configure the component for the look and feel, including the following:
LayoutManager
on the component if necessary. PropertyChangeListener
on the component in order to detect and respond to component property changes appropriately. installUI
in class ComponentUI
c
- the component where this UI delegate is being installedComponentUI.uninstallUI(javax.swing.JComponent)
, JComponent.setUI(javax.swing.plaf.ComponentUI)
, JComponent.updateUI()
public void uninstallUI(JComponent c)
Description copied from class: ComponentUI
Reverses configuration which was done on the specified component during installUI
. This method is invoked when this UIComponent
instance is being removed as the UI delegate for the specified component. This method should undo the configuration performed in installUI
, being careful to leave the JComponent
instance in a clean state (no extraneous listeners, look-and-feel-specific property objects, etc.). This should include the following:
uninstallUI
in class ComponentUI
c
- the component from which this UI delegate is being removed; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentsComponentUI.installUI(javax.swing.JComponent)
, JComponent.updateUI()
protected LayoutManager createLayoutManager()
Invoked by installUI
to create a layout manager object to manage the JTabbedPane
.
BasicTabbedPaneUI.TabbedPaneLayout
, JTabbedPane.getTabLayoutPolicy()
protected void installComponents()
Creates and installs any required subcomponents for the JTabbedPane. Invoked by installUI.
protected JButton createScrollButton(int direction)
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.
direction
- One of the SwingConstants constants: SOUTH, NORTH, EAST or WESTIllegalArgumentException
- if direction is not one of NORTH, SOUTH, EAST or WESTJTabbedPane.setTabPlacement(int)
, SwingConstants
protected void uninstallComponents()
Removes any installed subcomponents from the JTabbedPane. Invoked by uninstallUI.
protected void installDefaults()
protected void uninstallDefaults()
protected void installListeners()
protected void uninstallListeners()
protected MouseListener createMouseListener()
protected FocusListener createFocusListener()
protected ChangeListener createChangeListener()
protected PropertyChangeListener createPropertyChangeListener()
protected void installKeyboardActions()
protected void uninstallKeyboardActions()
protected void setRolloverTab(int index)
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.
index
- Index of the tab the mouse is over.protected int getRolloverTab()
Returns the tab the mouse is currently over, or -1
if the mouse is no longer over any tab.
-1
if the mouse is no longer over any tabpublic Dimension getMinimumSize(JComponent c)
Description copied from class: ComponentUI
Returns the specified component's minimum size appropriate for the look and feel. If null
is returned, the minimum size will be calculated by the component's layout manager instead (this is the preferred approach for any component with a specific layout manager installed). The default implementation of this method invokes getPreferredSize
and returns that value.
getMinimumSize
in class ComponentUI
c
- the component whose minimum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentsDimension
object or null
JComponent.getMinimumSize()
, LayoutManager.minimumLayoutSize(java.awt.Container)
, ComponentUI.getPreferredSize(javax.swing.JComponent)
public Dimension getMaximumSize(JComponent c)
Description copied from class: ComponentUI
Returns the specified component's maximum size appropriate for the look and feel. If null
is returned, the maximum size will be calculated by the component's layout manager instead (this is the preferred approach for any component with a specific layout manager installed). The default implementation of this method invokes getPreferredSize
and returns that value.
getMaximumSize
in class ComponentUI
c
- the component whose maximum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple componentsDimension
object or null
JComponent.getMaximumSize()
, LayoutManager2.maximumLayoutSize(java.awt.Container)
public int getBaseline(JComponent c, int width, int height)
Returns the baseline.
getBaseline
in class ComponentUI
c
- JComponent
baseline is being requested forwidth
- the width to get the baseline forheight
- the height to get the baseline forNullPointerException
- if c
is null
IllegalArgumentException
- if width or height is < 0JComponent.getBaseline(int, int)
public Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
Returns an enum indicating how the baseline of the component changes as the size changes.
getBaselineResizeBehavior
in class ComponentUI
c
- JComponent
to return baseline resize behavior forNullPointerException
- if c
is null
JComponent.getBaseline(int, int)
protected int getBaseline(int tab)
Returns the baseline for the specified tab.
tab
- index of tab to get baseline forIndexOutOfBoundsException
- if index is out of range (index < 0 || index >= tab count)protected int getBaselineOffset()
Returns the amount the baseline is offset by. This is typically the same as getTabLabelShiftY
.
public void paint(Graphics g, JComponent c)
Description copied from class: ComponentUI
Paints the specified component appropriately for the look and feel. This method is invoked from the ComponentUI.update
method when the specified component is being painted. Subclasses should override this method and use the specified Graphics
object to render the content of the component.
paint
in class ComponentUI
g
- the Graphics
context 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 componentsComponentUI.update(java.awt.Graphics, javax.swing.JComponent)
protected void paintTabArea(Graphics g, int tabPlacement, int selectedIndex)
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.
g
- the graphics object to use for renderingtabPlacement
- the placement for the tabs within the JTabbedPaneselectedIndex
- the tab index of the selected componentprotected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect)
protected void layoutLabel(int tabPlacement, FontMetrics metrics, int tabIndex, String title, Icon icon, Rectangle tabRect, Rectangle iconRect, Rectangle textRect, boolean isSelected)
protected void paintIcon(Graphics g, int tabPlacement, int tabIndex, Icon icon, Rectangle iconRect, boolean isSelected)
protected void paintText(Graphics g, int tabPlacement, Font font, FontMetrics metrics, int tabIndex, String title, Rectangle textRect, boolean isSelected)
protected int getTabLabelShiftX(int tabPlacement, int tabIndex, boolean isSelected)
protected int getTabLabelShiftY(int tabPlacement, int tabIndex, boolean isSelected)
protected void paintFocusIndicator(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect, boolean isSelected)
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
this function draws the border around each tab note that this function does now draw the background of the tab. that is done elsewhere
protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex, int x, int y, int w, int h, boolean isSelected)
protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex)
protected void paintContentBorderTopEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
protected void paintContentBorderLeftEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
protected void paintContentBorderBottomEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
protected void paintContentBorderRightEdge(Graphics g, int tabPlacement, int selectedIndex, int x, int y, int w, int h)
public Rectangle getTabBounds(JTabbedPane pane, int i)
Returns the bounds of the specified tab index. The bounds are with respect to the JTabbedPane's coordinate space.
getTabBounds
in class TabbedPaneUI
public int getTabRunCount(JTabbedPane pane)
getTabRunCount
in class TabbedPaneUI
public int tabForCoordinate(JTabbedPane pane, int x, int y)
Returns the tab index which intersects the specified point in the JTabbedPane's coordinate space.
tabForCoordinate
in class TabbedPaneUI
protected Rectangle getTabBounds(int tabIndex, Rectangle dest)
Returns the bounds of the specified tab in the coordinate space of the JTabbedPane component. This is required because the tab rects are by default defined in the coordinate space of the component where they are rendered, which could be the JTabbedPane (for WRAP_TAB_LAYOUT) or a ScrollableTabPanel (SCROLL_TAB_LAYOUT). This method should be used whenever the tab rectangle must be relative to the JTabbedPane itself and the result should be placed in a designated Rectangle object (rather than instantiating and returning a new Rectangle each time). The tab index parameter must be a valid tabbed pane tab index (0 to tab count - 1, inclusive). The destination rectangle parameter must be a valid Rectangle
instance. The handling of invalid parameters is unspecified.
tabIndex
- the index of the tabdest
- the rectangle where the result should be placedprotected Component getVisibleComponent()
protected void setVisibleComponent(Component component)
protected void assureRectsCreated(int tabCount)
protected void expandTabRunsArray()
protected int getRunForTab(int tabCount, int tabIndex)
protected int lastTabInRun(int tabCount, int run)
protected int getTabRunOverlay(int tabPlacement)
protected int getTabRunIndent(int tabPlacement, int run)
protected boolean shouldPadTabRun(int tabPlacement, int run)
protected boolean shouldRotateTabRuns(int tabPlacement)
protected Icon getIconForTab(int tabIndex)
protected View getTextViewForTab(int 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. This is provided to support html rendering inside tabs.
tabIndex
- the index of the tabprotected int calculateTabHeight(int tabPlacement, int tabIndex, int fontHeight)
protected int calculateMaxTabHeight(int tabPlacement)
protected int calculateTabWidth(int tabPlacement, int tabIndex, FontMetrics metrics)
protected int calculateMaxTabWidth(int tabPlacement)
protected int calculateTabAreaHeight(int tabPlacement, int horizRunCount, int maxTabHeight)
protected int calculateTabAreaWidth(int tabPlacement, int vertRunCount, int maxTabWidth)
protected Insets getTabInsets(int tabPlacement, int tabIndex)
protected Insets getSelectedTabPadInsets(int tabPlacement)
protected Insets getTabAreaInsets(int tabPlacement)
protected Insets getContentBorderInsets(int tabPlacement)
protected FontMetrics getFontMetrics()
protected void navigateSelectedTab(int direction)
protected void selectNextTabInRun(int current)
protected void selectPreviousTabInRun(int current)
protected void selectNextTab(int current)
protected void selectPreviousTab(int current)
protected void selectAdjacentRunTab(int tabPlacement, int tabIndex, int offset)
protected int getFocusIndex()
Returns the index of the tab that has focus.
protected int getTabRunOffset(int tabPlacement, int tabCount, int tabIndex, boolean forward)
protected int getPreviousTabIndex(int base)
protected int getNextTabIndex(int base)
protected int getNextTabIndexInRun(int tabCount, int base)
protected int getPreviousTabIndexInRun(int tabCount, int base)
protected int getPreviousTabRun(int baseRun)
protected int getNextTabRun(int baseRun)
protected static void rotateInsets(Insets topInsets, Insets targetInsets, int targetPlacement)
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.