| org.netbeans.swing.tabcontrol.plaf.AbstractTabDisplayerUI org.netbeans.swing.tabcontrol.plaf.BasicTabDisplayerUI
All known Subclasses: org.netbeans.swing.tabcontrol.plaf.BasicScrollingTabDisplayerUI,
BasicTabDisplayerUI | abstract public class BasicTabDisplayerUI extends AbstractTabDisplayerUI (Code) | | Base class for tab displayer UIs which use cell renderers to display tabs.
This class does not contain much logic itself, but rather acts to connect events
and data from various objects relating to the tab displayer, which it creates and
installs. Basically, the things that are involved are:
- A layout model (
TabLayoutModel ) - A data model providing the positions and sizes of tabs
- A state model (
TabState ) - A data model which tracks state data (selected, pressed, etc.)
for each tab, and can be queried when a tab is painted to determine how that should be done.
- A selection model (
javax.swing.SingleSelectionModel ) - Which tracks which tab is selected
- The
TabDisplayer component itself
- The
TabDisplayer 's data model, which contains the list of tab names, their icons and
tooltips and the user object (or
java.awt.Component ) they identify
- Assorted listeners on the component and data models, specifically
- A mouse listener that tells the state model when a state-affecting event
has happened, such as the mouse entering a tab
- A change listener that repaints appropriately when the selection changes
- A property change listener to trigger any repaints needed due to property
changes on the displayer component
- A component listener to attach and detach listeners when the component is shown/
hidden, and if neccessary, notify the layout model when the component is resized
- A default
TabCellRenderer , which is what will actually paint the tabs, and which
is also responsible for providing some miscellaneous data such as the number of
pixels the layout model should add to tab widths to make room for decorations,
etc.
The usage pattern of this class is similar to other
javax.swing.plaf.ComponentUI subclasses -
javax.swing.plaf.ComponentUI.installUI is called via
JComponent.updateUI . installUI initializes protected fields which
subclasses will need, in a well defined way; abstract methods are provided for subclasses to
create these objects (such as the things listed above), and convenience implementations of some
are provided. Under no circumstances should subclasses modify these protected fields -
due to the circuitousness of the way Swing installs UIs, they cannot be declared final, but should
be treated as read-only.
The goal of this class is to make it quite easy to implement new appearances
for tabs: To create a new appearance, implement a
TabCellRenderer that can
paint individual tabs as desired. This is made even easier via the
TabPainter interface - simply create the painting logic needed there. Then
subclass BasicTabDisplayerUI and include any painting logic for the background,
scroll buttons, etc. needed. A good example is
AquaEditorTabDisplayerUI .
|
Inner Class :protected class BasicTabState extends TabState | |
Inner Class :protected class BasicSelectionListener implements ChangeListener | |
pixelsToAdd | int pixelsToAdd(Code) | | |
repaintPolicy | protected int repaintPolicy(Code) | | |
cancelRequestAttention | final protected void cancelRequestAttention(int tab)(Code) | | |
createDefaultRenderer | abstract protected TabCellRenderer createDefaultRenderer()(Code) | | Create the default cell renderer for this control. If it is desirable to
have more than one renderer, override getTabCellRenderer()
|
createImageOfTab | public Image createImageOfTab(int index)(Code) | | |
createModelListener | protected ModelListener createModelListener()(Code) | | |
createRepaintPolicy | protected int createRepaintPolicy()(Code) | | Create the policy that will determine what types of events trigger a repaint of one or more tabs.
This is a bitmask composed of constants defined in TabState. The default value is
TabState.REPAINT_SELECTION_ON_ACTIVATION_CHANGE
| TabState.REPAINT_ON_SELECTION_CHANGE
| TabState.REPAINT_ON_MOUSE_ENTER_TAB
| TabState.REPAINT_ON_MOUSE_ENTER_CLOSE_BUTTON
| TabState.REPAINT_ON_MOUSE_PRESSED;
The repaint policy that should be used in conjunction with mouse events to determine when arepaint is needed. |
createTabState | protected TabState createTabState()(Code) | | Create a TabState instance. TabState manages the state of tabs - that is, which one
contains the mouse, which one is pressed, and so forth, providing methods such as
setMouseInTab(int tab) . Its getState() method returns a bitmask of
states a tab may have which affect the way it is painted.
Usage: It is expected that UIs will subclass TabState, to implement the
repaint methods, and possibly override getState(int tab) to mix
additional state bits into the bitmask. For example, scrollable tabs have the
possible states CLIP_LEFT and CLIP_RIGHT; BasicScrollingTabDisplayerUI's
implementation of this determines these states by consulting its layout model, and
adds them in when appropriate.
An implementation of TabState See Also: BasicTabDisplayerUI.BasicTabState See Also: BasicScrollingTabDisplayerUI.ScrollingTabState |
dropIndexOfPoint | public int dropIndexOfPoint(Point p)(Code) | | |
getExactTabIndication | public Polygon getExactTabIndication(int index)(Code) | | |
getFirstVisibleTab | protected int getFirstVisibleTab()(Code) | | Scrollable implementations will override this method to provide the first
visible (even if clipped) tab. The default implementation returns 0 if
there is at least one tab in the data model, or -1 to indicate the model
is completely empty
|
getInsertTabIndication | public Polygon getInsertTabIndication(int index)(Code) | | |
getLastKnownMouseLocation | final protected Point getLastKnownMouseLocation()(Code) | | |
getLastVisibleTab | protected int getLastVisibleTab()(Code) | | Scrollable implementations will override this method to provide the last
visible (even if clipped) tab. The default implementation returns 0 if
there is at least one tab in the data model, or -1 to indicate the model
is completely empty
|
getTabAreaInsets | abstract public Insets getTabAreaInsets()(Code) | | Return a set of insets defining the margins into which tabs should not be
painted. Subclasses that want to paint some controls to the right of the
tabs should include space for those controls in these insets. If a
bottom margin under the tabs is to be painted, include that as well.
|
getTabCellRenderer | protected TabCellRenderer getTabCellRenderer(int tab)(Code) | | Get the cell renderer for a given tab. The default implementation simply
returns the renderer created by createDefaultRenderer().
|
getTabRectForRepaint | protected Rectangle getTabRectForRepaint(int tab, Rectangle rect)(Code) | | Rectangle of the tab to be repainted |
getTabsVisibleArea | final protected void getTabsVisibleArea(Rectangle rect)(Code) | | Set the passed rectangle's bounds to the recangle in which tabs will be
painted; if your look and feel reserves some part of the tab area for its
own painting. The rectangle is determined by what is returned by
getTabAreaInsets() - this is simply a convenience method for finding the
rectange into which tabs will be painted.
|
install | protected void install()(Code) | | Overridden to initialize the tabState and defaultRenderer .
|
isAntialiased | protected boolean isAntialiased()(Code) | | |
modelChanged | protected void modelChanged()(Code) | | |
paint | final public void paint(Graphics g, JComponent c)(Code) | | Paints the tab control. Calls paintBackground(), then paints the tabs using
their cell renderers,
then calls paintAfterTabs
|
paintAfterTabs | protected void paintAfterTabs(Graphics g)(Code) | | Override this method to provide painting of areas outside the tabs
rectangle, such as margins and controls
|
paintBackground | protected void paintBackground(Graphics g)(Code) | | Fill in the background of the component prior to painting the tabs. The default
implementation does nothing. If it's just a matter of filling in a background color,
setOpaque (true) on the displayer, and ComponentUI.update() will take care of the rest.
|
processMouseWheelEvent | protected void processMouseWheelEvent(MouseWheelEvent e)(Code) | | Convenience method to override for handling mouse wheel events. The
defualt implementation does nothing.
|
requestAttention | final protected void requestAttention(int tab)(Code) | | |
tabForCoordinate | public int tabForCoordinate(Point p)(Code) | | |
uninstall | protected void uninstall()(Code) | | |
|
|