|
org.netbeans.swing.tabcontrol 1.8 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
org.netbeans.swing.tabcontrol.plaf.AbstractTabCellRenderer
public abstract class AbstractTabCellRenderer
Base class for tab renderers for the tab control. This is a support class which will allow authors who want to provide a different look or behavior for tabbed controls with a minimum of coding. The main methods of interest are
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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JLabel |
---|
JLabel.AccessibleJLabel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class javax.swing.JLabel |
---|
labelFor |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields 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 |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
AbstractTabCellRenderer(TabPainter painter,
Dimension padding)
|
|
AbstractTabCellRenderer(TabPainter leftClip,
TabPainter noClip,
TabPainter rightClip,
Dimension padding)
Creates a new instance of AbstractTabCellRenderer |
Method Summary | |
---|---|
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. |
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 |
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 |
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 |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AbstractTabCellRenderer(TabPainter leftClip, TabPainter noClip, TabPainter rightClip, Dimension padding)
public AbstractTabCellRenderer(TabPainter painter, Dimension padding)
Method Detail |
---|
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 evaluated
public 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 MouseEvent
protected 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 isNextTabSelected()
protected final boolean isNextTabArmed()
protected final boolean isPreviousTabSelected()
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()
protected int getIconYAdjustment()
protected 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
|
org.netbeans.swing.tabcontrol 1.8 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |