public abstract class AbstractTabCellRenderer extends JLabel implements TabCellRenderer
stateChanged()
- where the component should be
configured to render a given tabgetState()
- where the
current state is to be found at the time stateChanged is called
Typical usage is to pass one or more TabPainter objects to the constructor
which will be responsible for doing the actual painting, calling the convenience
getters in this class (such as isSelected
) to determine how
to paint.
JLabel.AccessibleJLabel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
AbstractTabCellRenderer(TabPainter painter,
Dimension padding) |
AbstractTabCellRenderer(TabPainter leftClip,
TabPainter noClip,
TabPainter rightClip,
Dimension padding)
Creates a new instance of AbstractTabCellRenderer
|
Modifier and Type | Method and Description |
---|---|
void |
addContainerListener(ContainerListener cl)
Overridden to be a no-op for performance reasons
|
void |
addHierarchyBoundsListener(HierarchyBoundsListener hbl)
Overridden to be a no-op for performance reasons
|
void |
addHierarchyListener(HierarchyListener hl)
Overridden to be a no-op for performance reasons
|
protected void |
firePropertyChange(String s,
Object a,
Object b)
Overridden to be a no-op for performance reasons
|
protected int |
getCaptionYAdjustment()
Return non-zero to shift the text up or down by the specified number of pixels when painting.
|
protected int |
getCaptionYPosition(Graphics g)
Get the Y position of the caption.
|
String |
getCommandAtPoint(Point p,
int tabState,
Rectangle bounds)
Get a command string which is identified with a region of the tab cell
renderer, such as TabbedContainer.COMMAND_CLOSE if the point is inside the
close button, or TabbedContainer.COMMAND_SELECT if the point is over the
tab title.
|
String |
getCommandAtPoint(Point p,
int tabState,
Rectangle bounds,
int mouseButton,
int eventType,
int modifiers)
Get a command string which is identified with a region of the tab cell
renderer, such as TabbedContainer.COMMAND_CLOSE if the point is inside the
close button, or TabbedContainer.COMMAND_SELECT if the point is over the
tab title.
|
protected int |
getIconYAdjustment()
Return non-zero to shift the icon up or down by the specified number of pixels when painting.
|
Dimension |
getPadding()
Returns the number of pixels this renderer wants added to the base width
and height of the icon and text to fit decorations such as close butons,
drag indicators, etc.
|
int |
getPixelsToAddToSelection()
Subclasses which want to make the selected tab wider than it would otherwise be should return a value
greater than 0 here.
|
JComponent |
getRendererComponent(TabData data,
Rectangle bounds,
int state)
Implementation of getRendererComponent from TabCellRenderer.
|
Color |
getSelectedActivatedBackground() |
Color |
getSelectedActivatedForeground() |
Color |
getSelectedBackground() |
Color |
getSelectedForeground() |
int |
getState()
Returns the state as set up in getRendererComponent
|
Polygon |
getTabShape(int tabState,
Rectangle bounds)
Get the shape of the tab.
|
protected boolean |
inCloseButton() |
protected boolean |
isActive()
Convenience getter to determine if the current state includes the active
state (a component in the container or the container itself has keyboard
focus)
|
protected boolean |
isArmed()
Convenience getter to determine if the current state includes the armed
state (the mouse is in the tab the component is currently configured to
render).
|
protected boolean |
isAttention() |
protected boolean |
isBusy() |
protected boolean |
isClipLeft()
Convenience getter to determine if the current state includes the
left-clipped state (the right hand side of the tab is not visible).
|
protected boolean |
isClipRight()
Convenience getter to determine if the current state includes the
right-clipped state (the right hand side of the tab is not visible).
|
protected boolean |
isHighlight() |
protected boolean |
isLeftmost()
Convenience getter to determine if the current state indicates
that the renderer is currently configured as the leftmost (non-clipped).
|
protected boolean |
isNextTabArmed()
Convenience getter to determine if the current state indicates
that the renderer is currently configured appears to the left of
the armed tab.
|
protected boolean |
isNextTabSelected()
Convenience getter to determine if the current state indicates
that the renderer is currently configured appears to the left of
the selected tab.
|
protected boolean |
isPressed()
Convenience getter to determine if the current state includes the pressed
state (the mouse is in the tab this component is currently configured to
render, and the mouse button is currently down)
|
protected boolean |
isPreviousTabSelected()
Convenience getter to determine if the current state indicates
that the renderer is currently configured appears to the right of
the selected tab.
|
protected boolean |
isRightmost()
Convenience getter to determine if the current state indicates
that the renderer is currently configured as the rightmost (non-clipped).
|
protected boolean |
isSelected()
Convenience getter to determine if the current state includes the
selected state (the tab this component is currently configured to render
is the selected tab in a container)
|
boolean |
isShowCloseButton() |
void |
paintComponent(Graphics g)
Overridden to paint the interior of the polygon if the border is an instance of TabPainter.
|
protected void |
paintIconAndText(Graphics g)
Actually paints the icon and text (using the lightweight HTML renderer)
|
void |
repaint()
Overridden to be a no-op for performance reasons
|
void |
repaint(long tm)
Overridden to be a no-op for performance reasons
|
void |
repaint(long tm,
int x,
int y,
int w,
int h)
Overridden to be a no-op for performance reasons
|
void |
revalidate()
Overridden to be a no-op for performance reasons
|
void |
setShowCloseButton(boolean b) |
protected void |
setState(int state)
Set the state of the renderer, in preparation for painting it or evaluating a condition
(such as the position of the close button) for which it must be correctly configured).
|
protected int |
stateChanged(int oldState,
int newState) |
void |
validate()
Overridden to be a no-op for performance reasons
|
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validateTree
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public AbstractTabCellRenderer(TabPainter leftClip, TabPainter noClip, TabPainter rightClip, Dimension padding)
public AbstractTabCellRenderer(TabPainter painter, Dimension padding)
public final void setShowCloseButton(boolean b)
setShowCloseButton
in interface TabCellRenderer
public final boolean isShowCloseButton()
isShowCloseButton
in interface TabCellRenderer
public String getCommandAtPoint(Point p, int tabState, Rectangle bounds)
TabCellRenderer
getCommandAtPoint
in interface TabCellRenderer
p
- A point (presumably) within the bounds of the passed rectangletabState
- The state of the tab, such as selected, clip right, etc.bounds
- The bounds of the tab, defining the coordinate space in which
the point parameter should be evaluatedpublic String getCommandAtPoint(Point p, int tabState, Rectangle bounds, int mouseButton, int eventType, int modifiers)
TabCellRenderer
getCommandAtPoint (Point p, int tabState, Rectangle bounds)
-
that method is primarily used for painting logic (such as whether to
draw a rectangle around a close button); this one is to determine the
actual action, if any to perform. So it is free to return null, some
other action, etc.getCommandAtPoint
in interface TabCellRenderer
p
- A point (presumably) within the bounds of the passed rectangletabState
- The state of the tab, such as selected, clip right, etc.bounds
- The bounds of the tab, defining the coordinate space in which
the point parameter should be evaluatedmouseButton
- The mouse button used to produce the event, as defined in MouseEventeventType
- The event type, as defined in MouseEventmodifiers
- The modifiers mask, as defined in MouseEventprotected final boolean isArmed()
protected final boolean isActive()
protected final boolean isPressed()
protected final boolean isSelected()
protected final boolean isClipRight()
protected final boolean isClipLeft()
protected final boolean isLeftmost()
protected final boolean isRightmost()
protected final boolean isAttention()
protected final boolean isHighlight()
protected final boolean isNextTabSelected()
protected final boolean isNextTabArmed()
protected final boolean isPreviousTabSelected()
protected final boolean isBusy()
public Dimension getPadding()
TabCellRenderer
TabsUI.createDefaultRenderer()
. The values it returns
cannot be changed dynamically. The result will be passed as padX/padY
arguments to the constructor of DefaultTabLayoutModel (unless
createLayoutModel is overridden with some custom model - then all bets
are off).getPadding
in interface TabCellRenderer
protected final void setState(int state)
state
- public final int getState()
public final JComponent getRendererComponent(TabData data, Rectangle bounds, int state)
stateChanged()
to handle
any changes (background color, border, etc) necessary to reflect the
current state as returned by getState()
.getRendererComponent
in interface TabCellRenderer
protected int stateChanged(int oldState, int newState)
public void revalidate()
revalidate
in class JComponent
public void repaint()
public void validate()
public void repaint(long tm)
public void repaint(long tm, int x, int y, int w, int h)
repaint
in class JComponent
protected final void firePropertyChange(String s, Object a, Object b)
firePropertyChange
in class Component
public final void addHierarchyBoundsListener(HierarchyBoundsListener hbl)
addHierarchyBoundsListener
in class Component
public final void addHierarchyListener(HierarchyListener hl)
addHierarchyListener
in class Component
public final void addContainerListener(ContainerListener cl)
addContainerListener
in class Container
public void paintComponent(Graphics g)
paintComponent
in class JComponent
protected int getCaptionYAdjustment()
AbstractTabCellRenderer.getCaptionYPosition(Graphics)
.protected int getIconYAdjustment()
protected int getCaptionYPosition(Graphics g)
AbstractTabCellRenderer.getCaptionYAdjustment()
based on it).g
- The graphics contextprotected void paintIconAndText(Graphics g)
g
- The graphics contextpublic Polygon getTabShape(int tabState, Rectangle bounds)
getTabShape
in interface TabCellRenderer
public Color getSelectedBackground()
getSelectedBackground
in interface TabCellRenderer
public Color getSelectedActivatedBackground()
getSelectedActivatedBackground
in interface TabCellRenderer
public Color getSelectedActivatedForeground()
public Color getSelectedForeground()
protected boolean inCloseButton()
public int getPixelsToAddToSelection()
getPixelsToAddToSelection
in interface TabCellRenderer