站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

TabbedContainer (Tab Control) - NetBeans API Javadoc (Current Development Version)

org.netbeans.swing.tabcontrol 1.8

org.netbeans.swing.tabcontrol
Class TabbedContainer

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.netbeans.swing.tabcontrol.TabbedContainer
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class TabbedContainer
extends JComponent
implements Accessible

A tabbed container similar to a JTabbedPane. The tabbed container is a simple container which contains two components - the tabs displayer, and the content displayer. The tabs displayer is the thing that actually draws the tabs; the content displayer contains the components that are being shown.

The first difference from a JTabbedPane is that it is entirely model driven - the tab contents are in a data model owned by the displayer. It is not strictly necessary for the contained components to even be installed in the AWT hierarchy when not displayed.

Other differences are more flexibility in the way tabs are displayed by completely separating the implementation and UI for that from that of displaying the contents.

Other interesting aspects are the ability of TabDataModel to deliver complex, granular events in a single pass with no information loss. Generally, great effort has been gone to to conflate nothing - that is, adding a component does not equal selecting it does not equal changing focus, et. cetera, leaving these decisions more in the hands of the user of the control.

It is possible to implement a subclass which provides the API of JTabbedPane, making it a drop-in replacement.

There are several UI styles a TabbedContainer can have. The type is passed as an argument to the constructor (support for changing these on the fly may be added in the future, but such a change is a very heavyweight operation, and is only desirable to enable use of this component in its various permutations inside GUI designers). The following styles are supported:

Customizing the appearance of tabs

Tabs are customized by providing a different UI delegate for the tab displayer component, via UIManager, in the same manner as any standard Swing component; for TYPE_SLIDING tabs, simply implementing an alternate UI delegate for the buttons used to represent tabs is all that is needed.

Managing user events on tabs

When a user clicks a tab, the TabbedContainer will fire an action event to all of its listeners. This action event will always be an instance of TabActionEvent, which can provide the index of the tab that was pressed, and the command name of the action that was performed. A client which wants to handle the event itself (for example, the asking a user if they want to save data, and possibly vetoing the closing of a tab) may veto (or take full responsibility for performing) the action by consuming the TabActionEvent.

Indication of focus and the "activated" state

The property active is provided to allow a tabbed container to indicate that it contains the currently focused component. However, no effort is made to track focus on the part of the tabbed control - there is too much variability possible (for example, if a component inside a tab opens a modal dialog, is the tab active or not?). In fact, using keyboard focus at all to manage the activated state of the component turns out to be a potent source of hard-to-fix, hard-to-reproduce bugs (especially when components are being added and removed, or hidden and shown or components which do not reliably produce focus events). What NetBeans does to solve the problem in a reliable way is the following:
  1. Use an AWT even listener to track mouse clicks, and when the mouse is clicked,
    • Find the ancestor that is a tabbed container (if any)
    • Set the activated state appropriately on it and the previously active container
    • Ensure that keyboard focus moves into that container
  2. Block ctrl-tab style keyboard based focus traversal out of tabbed containers
  3. Provide keyboard actions, with menu items, which will change to a different container, activating it
This may seem complicated, and it probably is overkill for a small application (as is this tabbed control - it wasn't designed for a small application). It's primary advantage is that it works.

See Also:
TabDisplayer, Serialized Form

Nested Class Summary
 
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
static String COMMAND_CLOSE
          Action command indicating that the action event signifies the user clicking the Close button on a tab.
static String COMMAND_CLOSE_ALL
           
static String COMMAND_CLOSE_ALL_BUT_THIS
           
static String COMMAND_DISABLE_AUTO_HIDE
           
static String COMMAND_ENABLE_AUTO_HIDE
           
static String COMMAND_MAXIMIZE
          Command indicating a maximize (double-click) request
static String COMMAND_POPUP_REQUEST
          Action command indicating that a popup menu should be shown
static String COMMAND_SELECT
          Action command indicating that the action event fired signifies the user selecting a tab
static int CONTENT_POLICY_ADD_ALL
          Content policy in which all components contained in the data model should immediately be added to the AWT hierarchy at the time they appear in the data model.
static int CONTENT_POLICY_ADD_ON_FIRST_USE
          Content policy by which components contained in the data model are added to the AWT hierarchy the first time they are shown, and remain their thereafter unless removed from the data model.
static int CONTENT_POLICY_ADD_ONLY_SELECTED
          Content policy by which components contained in the data model are added to the AWT hierarchy the when they are shown, and removed immediately when the user changes tabs.
protected static int DEFAULT_CONTENT_POLICY
          The default content policy, currently CONTENT_POLICY_ADD_ALL.
static String PROP_ACTIVE
          Property fired when setActive() is called
static String PROP_MANAGE_TAB_POSITION
          Client property applicable only to TYPE_SLIDING tabs.
static String TABBED_CONTAINER_UI_CLASS_ID
          UIManager key for the UI Delegate to be used by tabbed containers.
static int TYPE_EDITOR
          Creates a "editor" style displayer; typically this uses a scrolling tabs UI for the tab displayer.
static int TYPE_SLIDING
          Creates a "sliding" view, typically with tabs rendered as buttons along the left, bottom or right edge, with no scrolling behavior for tabs.
static int TYPE_TOOLBAR
          Creates a Toolbar-style displayer (the style used by the NetBeans Form Editor's Component Inspector and a few other places in NetBeans).
static int TYPE_VIEW
          Creates a "view" style displayer; typically this will have a fixed width and a single row of tabs which get smaller as more tabs are added, as seen in NetBeans’ Explorer window.
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TabbedContainer()
          Create a new pane with the default model and tabs displayer
TabbedContainer(int type)
           
TabbedContainer(TabDataModel model)
          Create a new pane with asociated model and the default tabs displayer
TabbedContainer(TabDataModel model, int type)
          Create a new pane with the specified model and displayer type
TabbedContainer(TabDataModel model, int type, LocationInformer locationInformer)
          Deprecated. 
TabbedContainer(TabDataModel model, int type, WinsysInfoForTabbed winsysInfo)
          Create a new pane with the specified model, displayer type and extra information from winsys
 
Method Summary
 void addActionListener(ActionListener listener)
          Register an ActionListener.
 void cancelRequestAttention(int tab)
           
 void cancelRequestAttention(TabData data)
           
 Image createImageOfTab(int idx)
          Create an image of a single tab, suitable for use in drag and drop operations
 int dropIndexOfPoint(Point location)
          The index at which a tab should be inserted if a drop operation occurs at this point.
 AccessibleContext getAccessibleContext()
           
 ComponentConverter getComponentConverter()
          Get the component converter which is used to fetch a component corresponding to an element in the data model.
 int getContentPolicy()
          Determine the policy by which components are added to the container.
 Shape getDropIndication(Object dragged, Point location)
          Get a shape appropriate for drawing on the window's glass pane to indicate where a component should appear in the tab order if it is dropped here.
 LocationInformer getLocationInformer()
          Deprecated. 
 TabDataModel getModel()
          Get the data model that represents the tabs this component has.
 SingleSelectionModel getSelectionModel()
          Get the selection model.
 int getTabCount()
          Get the number of tabs.
 Rectangle getTabRect(int index, Rectangle r)
          Fetch the rectangle of the tab for a given index, in the coordinate space of this component, by reconfiguring the passed rectangle object
 int getType()
          Get the type of this displayer - it is either TYPE_EDITOR or TYPE_VIEW.
 TabbedContainerUI getUI()
          Get the ui delegate for this component
 String getUIClassID()
          Returns TabbedContainer.TABBED_CONTAINER_UI_CLASS_ID
 WinsysInfoForTabbed getWinsysInfo()
           
 int indexOf(Component comp)
          Get the index of a component
 boolean isActive()
          Determine if this component thinks it is "active", which affects how the tabs are painted - typically used to indicate that keyboard focus is somewhere within the component
 boolean isPaintingOrigin()
           
 boolean isShowCloseButton()
          Determine whether or not close buttons are being shown.
 boolean isValidateRoot()
           
protected  void postActionEvent(TabActionEvent event)
          Used by the UI to post action events for selection and close operations.
 void removeActionListener(ActionListener listener)
          Remove an action listener.
 void requestAttention(int tab)
          Cause the tab at the specified index to blink or otherwise suggest that the user should click it.
 boolean requestAttention(TabData data)
          Cause the specified tab to blink or otherwisse suggest that the user should click it.
 void setActive(boolean active)
          Set the "active" state of this tab control - this affects the way the tabs are displayed, to indicate focus.
 void setComponentConverter(ComponentConverter cc)
          Set the converter that converts user objects in the data model into components to display.
 void setContentPolicy(int i)
          Experimental property - alter the policy by which the components in the model are added to the container.
 void setIconAt(int index, Icon icon)
           
 void setShowCloseButton(boolean val)
          Set whether or not close buttons should be shown.
 void setTitleAt(int index, String title)
           
 void setToolTipTextAt(int index, String toolTip)
           
 int tabForCoordinate(Point p)
          Gets the index of the tab at point p, or -1 if no tab is there
 void updateUI()
          Overridden as follows: When called by the superclass constructor (before the type field is set), it will simply return; the TabbedContainer constructor will call updateUI() explicitly later.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, 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
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, 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, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, 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, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TABBED_CONTAINER_UI_CLASS_ID

public static final String TABBED_CONTAINER_UI_CLASS_ID
UIManager key for the UI Delegate to be used by tabbed containers.

See Also:
Constant Field Values

TYPE_VIEW

public static final int TYPE_VIEW
Creates a "view" style displayer; typically this will have a fixed width and a single row of tabs which get smaller as more tabs are added, as seen in NetBeans’ Explorer window.

See Also:
Constant Field Values

TYPE_EDITOR

public static final int TYPE_EDITOR
Creates a "editor" style displayer; typically this uses a scrolling tabs UI for the tab displayer. This is the most scalable of the available UI styles - it can handle a very large number of tabs with minimal overhead, and the standard UI implementations of it use a cell-renderer model for painting.

See Also:
Constant Field Values

TYPE_SLIDING

public static final int TYPE_SLIDING
Creates a "sliding" view, typically with tabs rendered as buttons along the left, bottom or right edge, with no scrolling behavior for tabs. Significant about this UI style is that re-clicking the selected tab will cause the component displayed to be hidden.

This is the least scalable of the available UI types, and is intended primarily for use with a small, fixed set of tabs. By default, the position of the tab displayer will be determined based on the proximity of the container to the edges of its parent window. This can be turned off by setting the client property PROP_MANAGE_TAB_POSITION to Boolean.FALSE.

See Also:
Constant Field Values

TYPE_TOOLBAR

public static final int TYPE_TOOLBAR
Creates a Toolbar-style displayer (the style used by the NetBeans Form Editor's Component Inspector and a few other places in NetBeans).

See Also:
Constant Field Values

PROP_ACTIVE

public static final String PROP_ACTIVE
Property fired when setActive() is called

See Also:
Constant Field Values

PROP_MANAGE_TAB_POSITION

public static final String PROP_MANAGE_TAB_POSITION
Client property applicable only to TYPE_SLIDING tabs. If set to Boolean.FALSE, the UI will not automatically try to determine a correct position for the tab displayer.

See Also:
Constant Field Values

COMMAND_CLOSE

public static final String COMMAND_CLOSE
Action command indicating that the action event signifies the user clicking the Close button on a tab.

See Also:
Constant Field Values

COMMAND_SELECT

public static final String COMMAND_SELECT
Action command indicating that the action event fired signifies the user selecting a tab

See Also:
Constant Field Values

COMMAND_POPUP_REQUEST

public static final String COMMAND_POPUP_REQUEST
Action command indicating that a popup menu should be shown

See Also:
Constant Field Values

COMMAND_MAXIMIZE

public static final String COMMAND_MAXIMIZE
Command indicating a maximize (double-click) request

See Also:
Constant Field Values

COMMAND_CLOSE_ALL

public static final String COMMAND_CLOSE_ALL
See Also:
Constant Field Values

COMMAND_CLOSE_ALL_BUT_THIS

public static final String COMMAND_CLOSE_ALL_BUT_THIS
See Also:
Constant Field Values

COMMAND_ENABLE_AUTO_HIDE

public static final String COMMAND_ENABLE_AUTO_HIDE
See Also:
Constant Field Values

COMMAND_DISABLE_AUTO_HIDE

public static final String COMMAND_DISABLE_AUTO_HIDE
See Also:
Constant Field Values

CONTENT_POLICY_ADD_ALL

public static final int CONTENT_POLICY_ADD_ALL
Content policy in which all components contained in the data model should immediately be added to the AWT hierarchy at the time they appear in the data model.

See Also:
setContentPolicy(int), Constant Field Values

CONTENT_POLICY_ADD_ON_FIRST_USE

public static final int CONTENT_POLICY_ADD_ON_FIRST_USE
Content policy by which components contained in the data model are added to the AWT hierarchy the first time they are shown, and remain their thereafter unless removed from the data model.

See Also:
setContentPolicy(int), Constant Field Values

CONTENT_POLICY_ADD_ONLY_SELECTED

public static final int CONTENT_POLICY_ADD_ONLY_SELECTED
Content policy by which components contained in the data model are added to the AWT hierarchy the when they are shown, and removed immediately when the user changes tabs.

See Also:
Constant Field Values

DEFAULT_CONTENT_POLICY

protected static int DEFAULT_CONTENT_POLICY
The default content policy, currently CONTENT_POLICY_ADD_ALL. To facilitate experimentation with different settings application-wide, set the system property "nb.tabcontrol.contentpolicy" to 1, 2 or 3 for ADD_ALL, ADD_ON_FIRST_USE or ADD_ONLY_SELECTED, respectively (note other values will throw an Error). Do not manipulate this value at runtime, it will likely become a final field in a future release. It is a protected field only to ensure its inclusion in documentation.

See Also:
setContentPolicy(int)
Constructor Detail

TabbedContainer

public TabbedContainer()
Create a new pane with the default model and tabs displayer


TabbedContainer

public TabbedContainer(TabDataModel model)
Create a new pane with asociated model and the default tabs displayer


TabbedContainer

public TabbedContainer(int type)

TabbedContainer

public TabbedContainer(TabDataModel model,
                       int type)
Create a new pane with the specified model and displayer type

Parameters:
model - The model

TabbedContainer

@Deprecated
public TabbedContainer(TabDataModel model,
                                  int type,
                                  LocationInformer locationInformer)
Deprecated. 

Deprecated, please use constructor with WinsysInfoForTabbed instead.


TabbedContainer

public TabbedContainer(TabDataModel model,
                       int type,
                       WinsysInfoForTabbed winsysInfo)
Create a new pane with the specified model, displayer type and extra information from winsys

Method Detail

updateUI

public void updateUI()
Overridden as follows: When called by the superclass constructor (before the type field is set), it will simply return; the TabbedContainer constructor will call updateUI() explicitly later.

Will first search UIManager for a matching UI class. If non-null (by default it is set in the core/swing/plaf library), it will compare the found class name with the current UI. If they are a match, it will call TabbedContainerUI.shouldReplaceUI() to decide whether to actually do anything or not (in most cases it would just replace an instance of DefaultTabbedContainerUI with another one; but this call allows DefaultTabbedContainerUI.uichange() to update the tab displayer as needed).

If no UIManager UI class is defined, this method will silently use an instance of DefaultTabbedContainerUI.

Overrides:
updateUI in class JComponent

getType

public final int getType()
Get the type of this displayer - it is either TYPE_EDITOR or TYPE_VIEW. This property is set in the constructor and is immutable


getUIClassID

public String getUIClassID()
Returns TabbedContainer.TABBED_CONTAINER_UI_CLASS_ID

Overrides:
getUIClassID in class JComponent

getUI

public TabbedContainerUI getUI()
Get the ui delegate for this component


setComponentConverter

public final void setComponentConverter(ComponentConverter cc)
Set the converter that converts user objects in the data model into components to display. If set to null (the default), the user object at the selected index in the data model will be cast as an instance of JComponent when searching for what to show for a given tab.

For use cases where a single component is to be displayed for more than one tab, just reconfigured when the selection changes, simply supply a ComponentConverter.Fixed with the component that should be used for all tabs.


getComponentConverter

public final ComponentConverter getComponentConverter()
Get the component converter which is used to fetch a component corresponding to an element in the data model. If the value has not been set, it will use ComponentConverter.DEFAULT, which simply delegates to TabData.getComponent().


setContentPolicy

public final void setContentPolicy(int i)
Experimental property - alter the policy by which the components in the model are added to the container. This may not remain suppported. If used, it should be called before populating the data model.


getContentPolicy

public int getContentPolicy()
Determine the policy by which components are added to the container. There are various pros and cons to each:
  • CONTENT_POLICY_ADD_ALL - All components in the data model are automatically added to the container, and whenever the model changes, components are added and removed as need be. This is less scalable, but absolutely reliable
  • CONTENT_POLICY_ADD_ON_FIRST_USE - Components are not added to the container until the first time they are used, and then they remain in the AWT hierarchy until their TabData elements are removed from the model. This is more scalable, and probably has some startup time benefits
  • CONTENT_POLICY_ADD_ONLY_SELECTED - The only component that will ever be in the AWT hierarchy is the one that is being displayed. This is safest in the case that heavyweight AWT components may be used


isValidateRoot

public boolean isValidateRoot()
Overrides:
isValidateRoot in class JComponent

isPaintingOrigin

public boolean isPaintingOrigin()

setToolTipTextAt

public void setToolTipTextAt(int index,
                             String toolTip)

getModel

public final TabDataModel getModel()
Get the data model that represents the tabs this component has. All programmatic manipulation of tabs should be done via the data model.

Returns:
The model

getSelectionModel

public final SingleSelectionModel getSelectionModel()
Get the selection model. The selection model tracks the index of the selected component, modifying this index appropriately when tabs are added or removed.

Returns:
The model

getTabRect

public final Rectangle getTabRect(int index,
                                  Rectangle r)
Fetch the rectangle of the tab for a given index, in the coordinate space of this component, by reconfiguring the passed rectangle object


tabForCoordinate

public int tabForCoordinate(Point p)
Gets the index of the tab at point p, or -1 if no tab is there


setActive

public final void setActive(boolean active)
Set the "active" state of this tab control - this affects the way the tabs are displayed, to indicate focus. Note that this method will never be called automatically in stand-alone use of TabbedContainer. While one would expect a component gaining keyboard focus to be a good determinant, it actually turns out to be a potent source of subtle and hard-to-fix bugs.

NetBeans uses an AWTEventListener to track mouse clicks, and allows components to become activated only via a mouse click or via a keyboard action or menu item which activates the component. This approach is far more robust and is the recommended usage pattern.


requestAttention

public final void requestAttention(int tab)
Cause the tab at the specified index to blink or otherwise suggest that the user should click it.


cancelRequestAttention

public final void cancelRequestAttention(int tab)

requestAttention

public final boolean requestAttention(TabData data)
Cause the specified tab to blink or otherwisse suggest that the user should click it.


cancelRequestAttention

public final void cancelRequestAttention(TabData data)

isActive

public final boolean isActive()
Determine if this component thinks it is "active", which affects how the tabs are painted - typically used to indicate that keyboard focus is somewhere within the component


addActionListener

public final void addActionListener(ActionListener listener)
Register an ActionListener. TabbedContainer and TabDisplayer guarantee that the type of event fired will always be TabActionEvent. There are two special things about TabActionEvent:
  1. There are methods on TabActionEvent to find the index of the tab the event was performed on, and if present, retrieve the mouse event that triggered it, for clients that wish to provide different handling for different mouse buttons
  2. TabActionEvents can be consumed. If a listener consumes the event, the UI will take no action - the selection will not be changed, the tab will not be closed. Consuming the event means taking responsibility for doing whatever would normally happen automatically. This is useful for, for example, showing a dialog and possibly aborting closing a tab if it contains unsaved data, for instance.
Action events will be fired before any action has been taken to alter the state of the control to match the action, so that they may be vetoed or modified by consuming the event.

Parameters:
listener - The listener to register.

removeActionListener

public final void removeActionListener(ActionListener listener)
Remove an action listener.

Parameters:
listener - The listener to remove.

postActionEvent

protected final void postActionEvent(TabActionEvent event)
Used by the UI to post action events for selection and close operations. If the event is consumed, the UI should take no action to change the selection or close the tab, and will presume that the receiver of the event is handling performing whatever action is appropriate.

Parameters:
event - The event to be fired

setIconAt

public void setIconAt(int index,
                      Icon icon)

setTitleAt

public void setTitleAt(int index,
                       String title)

createImageOfTab

public Image createImageOfTab(int idx)
Create an image of a single tab, suitable for use in drag and drop operations


getTabCount

public int getTabCount()
Get the number of tabs. Equivalent to getModel().size()


setShowCloseButton

public final void setShowCloseButton(boolean val)
Set whether or not close buttons should be shown. This can be defaulted with the system property nb.tabs.suppressCloseButton; if the system property is not set, the default is true.


isShowCloseButton

public final boolean isShowCloseButton()
Determine whether or not close buttons are being shown.


indexOf

public int indexOf(Component comp)
Get the index of a component


dropIndexOfPoint

public int dropIndexOfPoint(Point location)
The index at which a tab should be inserted if a drop operation occurs at this point.

Parameters:
location - A point anywhere on the TabbedContainer
Returns:
A tab index, or -1

getDropIndication

public Shape getDropIndication(Object dragged,
                               Point location)
Get a shape appropriate for drawing on the window's glass pane to indicate where a component should appear in the tab order if it is dropped here.

Parameters:
dragged - An object being dragged, or null. The object may be an instance of TabData or Component, in which case a check will be done of whether the dragged object is already in the data model, so that attempts to drop the object over the place it already is in the model will always return the exact indication of that tab's position.
location - A point
Returns:
Drop indication drawing

getLocationInformer

@Deprecated
public LocationInformer getLocationInformer()
Deprecated. 


getWinsysInfo

public WinsysInfoForTabbed getWinsysInfo()

getAccessibleContext

public AccessibleContext getAccessibleContext()
Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in class JComponent

org.netbeans.swing.tabcontrol 1.8

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.