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

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

org.netbeans.swing.tabcontrol 1.8

org.netbeans.swing.tabcontrol.plaf
Class DefaultTabbedContainerUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by org.netbeans.swing.tabcontrol.TabbedContainerUI
          extended by org.netbeans.swing.tabcontrol.plaf.DefaultTabbedContainerUI

public class DefaultTabbedContainerUI
extends TabbedContainerUI

Default UI implementation for tabbed containers. Manages installing the tab contentDisplayer and content contentDisplayer components, and the relationship between the data models and selection models of the UI.

Note that there is typically little reasons to subclass this - to affect the display or behavior of the tabs, implement TabDisplayerUI, the UI delegate for the embedded component which displays the tabs.


Nested Class Summary
protected  class DefaultTabbedContainerUI.ContainerComponentListener
          A ComponentListener which listens for show/hide to add and remove the selection and model listeners
protected  class DefaultTabbedContainerUI.ContainerPropertyChangeListener
           
protected  class DefaultTabbedContainerUI.ModelListener
          This class does the heavy lifting of keeping the content of the content displayer up-to-date with the contents of the data model.
protected  class DefaultTabbedContainerUI.SelectionListener
          A ChangeListener which updates the component displayed in the content displayer with the selected component in the tab displayer's selection model
 
Field Summary
protected  ComponentListener componentListener
          Component listener which listens on the container, and attaches/detaches listeners.
protected  JComponent contentDisplayer
          The component which displays the selected component in the tabbed container.
protected  LayoutManager contentDisplayerLayout
          Layout manager which will handle layout of the tabbed container.
static String KEY_EDITOR_CONTENT_BORDER
          UIManager key for the border of the tab displayer in editor ui type.
static String KEY_EDITOR_OUTER_BORDER
          UIManager key for the border of the entire tabbed container in editor ui type
static String KEY_EDITOR_TABS_BORDER
          UIManager key for the border of the tab displayer in editor ui type
static String KEY_SLIDING_CONTENT_BORDER
          UIManager key for the border of the tab displayer in sliding ui type.
static String KEY_SLIDING_OUTER_BORDER
          UIManager key for the border of the entire tabbed container in sliding ui type
static String KEY_SLIDING_TABS_BORDER
          UIManager key for the border of the tab displayer in sliding ui type
static String KEY_TOOLBAR_CONTENT_BORDER
          UIManager key for the border of the tab displayer in toolbar ui type.
static String KEY_TOOLBAR_OUTER_BORDER
          UIManager key for the border of the entire tabbed container in toolbar ui type
static String KEY_TOOLBAR_TABS_BORDER
          UIManager key for the border of the tab displayer in toolbar ui type
static String KEY_VIEW_CONTENT_BORDER
          UIManager key for the border of the tab displayer in view ui type.
static String KEY_VIEW_OUTER_BORDER
          UIManager key for the border of the entire tabbed container in view ui type.
static String KEY_VIEW_TABS_BORDER
          UIManager key for the border of the tab displayer in view ui type.
protected  ComplexListDataListener modelListener
          Listener on the data model, which handles updating the contained components to keep them in sync with the contents of the data model.
protected  PropertyChangeListener propertyChangeListener
          Property change listener which detects changes on the tabbed container, such as its active state, which should be propagated to the tab displayer.
protected  ChangeListener selectionListener
          Change listener which tracks changes in the selection model and changes the displayed component to reflect the selected tab do not alter the value in this field.
protected  FxProvider slideEffectManager
          FxProvider which will provide transition effects when tabs are changed.
protected  TabDisplayer tabDisplayer
          The Displayer for the tabs.
 
Fields inherited from class org.netbeans.swing.tabcontrol.TabbedContainerUI
container
 
Constructor Summary
DefaultTabbedContainerUI(TabbedContainer c)
          Creates a new instance of DefaultTabbedContainerUI
 
Method Summary
protected  void attachModelAndSelectionListeners()
          Begin listening to the model for changes in the selection, which should cause us to update the displayed component in the content contentDisplayer.
protected  void cancelRequestAttention(int tab)
           
protected  ComponentListener createComponentListener()
          Create a component listener responsible for initializing the contentDisplayer component when the tabbed container is shown
protected  JPanel createContentDisplayer()
          Create the component which will contain the content (the components which correspond to tabs).
protected  LayoutManager createContentDisplayerLayout()
          Creates the content contentDisplayer's layout manager, responsible for ensuring that the correct component is on top and is the only one showing
protected  FxProvider createFxProvider()
          Create an FxProvider instance which will provide transition effects when tabs are selected.
 Image createImageOfTab(int idx)
          Create an image suitable for use in drag and drop operations, of a tab
protected  LayoutManager createLayout()
          Create the layout manager that will manage the layout of the TabbedContainer.
protected  ComplexListDataListener createModelListener()
          Create a listener for the TabDataModel.
protected  PropertyChangeListener createPropertyChangeListener()
          Create a property change listener which will update the tab displayer in accordance with property changes on the container.
protected  ChangeListener createSelectionListener()
          Create a ChangeListener which will listen to the selection model of the tab displayer, and update the displayed component in the displayer when the selection model changes.
protected  TabDisplayer createTabDisplayer()
          Create the component which will display the tabs.
static ComponentUI createUI(JComponent c)
           
protected  void detachModelAndSelectionListeners()
          Stop listening to the model for changes in the selection, which should cause us to update the displayed component in the content contentDisplayer, and changes in the data model which can affect the displayed component.
 int dropIndexOfPoint(Point p)
          Index at which a tab would be inserted if a suitable object were dropped at this point.
protected  void ensureSelectedComponentIsShowing()
          Ensures that the component the selection model says is selected is the one that is showing.
 Rectangle getContentArea()
          Get a rectangle matching the area in which content is displayed
 Polygon getExactTabIndication(int idx)
          Get a polygon matching the shape of the tab
 Polygon getInsertTabIndication(int idx)
          Get a polygon indicating the insertion of a tab before the passed index, unless the index is equal to the model size, in which case it will return an indication for inserting a tab at the end.
 SingleSelectionModel getSelectionModel()
          Get the selection model that tracks and determines which tab is selected.
 Rectangle getTabRect(int tab, Rectangle r)
          Get the bounds of a tab.
 Rectangle getTabsArea()
          Get a rectangle matching the area in which tabs are displayed
 Rectangle getTabsArea(Rectangle dest)
           
protected  void initDisplayer()
          Fills contentDisplayer container with components retrieved from model.
protected  void install()
          Subclasses may override this method to do anything they need to do on installUI().
protected  void installBorders()
          Installs borders on the container, content displayer and tab displayer
protected  void installContentDisplayer()
          Installs the content displayer component and its layout manager
protected  void installListeners()
          Installs a component listener on the component.
protected  void installTabDisplayer()
          Installs the tab displayer component into the container.
 void installUI(JComponent c)
          This method is final.
 boolean isShowCloseButton()
           
 void makeTabVisible(int tab)
          Make a tab visible.
protected  void requestAttention(int tab)
           
 void setShowCloseButton(boolean val)
           
protected  Component showComponent(Component c)
          Shows the passed component.
protected  void showComponentWithFxProvider(Component c)
          Shows a component in the control, using the FxProvider created in createFxProvider() to manage showing it.
 int tabForCoordinate(Point p)
          Get the tab at a given point in the coordinate space of the container.
protected  Component toComp(TabData data)
          Convenience method for fetching a component from a TabData object via the container's ComponentConverter
protected  boolean uichange()
          This method is called if TabbedContainer.updateUI() gets called after a UI delegate has been installed (in other words, the user did something like switch look and feels or switch the Windows desktop theme).
protected  void uninstall()
          Subclasses may override this method to do anything they need to do on uninstallUI().
protected  void uninstallDisplayers()
          Uninstalls and nulls references to the content contentDisplayer and tab contentDisplayer, and removes all components from the content contentDisplayer.
protected  void uninstallListeners()
          Uninstalls the component listener installed in installListeners()
 void uninstallUI(JComponent c)
          This method is final.
protected  void updateOrientation()
          Checks the position of the tabbed container relative to its parent window, and potentially updates its orientation client property.
 
Methods inherited from class org.netbeans.swing.tabcontrol.TabbedContainerUI
shouldPerformAction
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, getPreferredSize, paint, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_EDITOR_CONTENT_BORDER

public static final String KEY_EDITOR_CONTENT_BORDER
UIManager key for the border of the tab displayer in editor ui type.

See Also:
Constant Field Values

KEY_EDITOR_TABS_BORDER

public static final String KEY_EDITOR_TABS_BORDER
UIManager key for the border of the tab displayer in editor ui type

See Also:
Constant Field Values

KEY_EDITOR_OUTER_BORDER

public static final String KEY_EDITOR_OUTER_BORDER
UIManager key for the border of the entire tabbed container in editor ui type

See Also:
Constant Field Values

KEY_VIEW_CONTENT_BORDER

public static final String KEY_VIEW_CONTENT_BORDER
UIManager key for the border of the tab displayer in view ui type.

See Also:
Constant Field Values

KEY_VIEW_TABS_BORDER

public static final String KEY_VIEW_TABS_BORDER
UIManager key for the border of the tab displayer in view ui type.

See Also:
Constant Field Values

KEY_VIEW_OUTER_BORDER

public static final String KEY_VIEW_OUTER_BORDER
UIManager key for the border of the entire tabbed container in view ui type.

See Also:
Constant Field Values

KEY_SLIDING_CONTENT_BORDER

public static final String KEY_SLIDING_CONTENT_BORDER
UIManager key for the border of the tab displayer in sliding ui type.

See Also:
Constant Field Values

KEY_SLIDING_TABS_BORDER

public static final String KEY_SLIDING_TABS_BORDER
UIManager key for the border of the tab displayer in sliding ui type

See Also:
Constant Field Values

KEY_SLIDING_OUTER_BORDER

public static final String KEY_SLIDING_OUTER_BORDER
UIManager key for the border of the entire tabbed container in sliding ui type

See Also:
Constant Field Values

KEY_TOOLBAR_CONTENT_BORDER

public static final String KEY_TOOLBAR_CONTENT_BORDER
UIManager key for the border of the tab displayer in toolbar ui type.

See Also:
Constant Field Values

KEY_TOOLBAR_TABS_BORDER

public static final String KEY_TOOLBAR_TABS_BORDER
UIManager key for the border of the tab displayer in toolbar ui type

See Also:
Constant Field Values

KEY_TOOLBAR_OUTER_BORDER

public static final String KEY_TOOLBAR_OUTER_BORDER
UIManager key for the border of the entire tabbed container in toolbar ui type

See Also:
Constant Field Values

componentListener

protected ComponentListener componentListener
Component listener which listens on the container, and attaches/detaches listeners. do not alter the value in this field. To provide a different implementation, override the appropriate creation method.


selectionListener

protected ChangeListener selectionListener
Change listener which tracks changes in the selection model and changes the displayed component to reflect the selected tab do not alter the value in this field. To provide a different implementation, override the appropriate creation method.


modelListener

protected ComplexListDataListener modelListener
Listener on the data model, which handles updating the contained components to keep them in sync with the contents of the data model. do not alter the value in this field. To provide a different implementation, override the appropriate creation method.

See Also:
TabbedContainer.setContentPolicy(int)

contentDisplayerLayout

protected LayoutManager contentDisplayerLayout
Layout manager which will handle layout of the tabbed container. do not alter the value in this field. To provide a different implementation, override the appropriate creation method.


propertyChangeListener

protected PropertyChangeListener propertyChangeListener
Property change listener which detects changes on the tabbed container, such as its active state, which should be propagated to the tab displayer. do not alter the value in this field. To provide a different implementation, override the appropriate creation method.


slideEffectManager

protected FxProvider slideEffectManager
FxProvider which will provide transition effects when tabs are changed. By default, only used for TabbedContainer.TYPE_SLIDE tabs. do not alter the value in this field. To provide a different implementation, override the appropriate creation method.


contentDisplayer

protected JComponent contentDisplayer
The component which displays the selected component in the tabbed container. do not alter the value in this field. To provide a different implementation, override the appropriate creation method.


tabDisplayer

protected TabDisplayer tabDisplayer
The Displayer for the tabs. Normally an instance of TabDisplayer. To get the actual GUI component that is showing tabs, call its getComponent() method. do not alter the value in this field. To provide a different implementation, override the appropriate creation method.

Constructor Detail

DefaultTabbedContainerUI

public DefaultTabbedContainerUI(TabbedContainer c)
Creates a new instance of DefaultTabbedContainerUI

Method Detail

createUI

public static ComponentUI createUI(JComponent c)

installUI

public final void installUI(JComponent c)
This method is final. Subclasses which need to provide additional initialization should override install()

Overrides:
installUI in class TabbedContainerUI
Parameters:
c - A JComponent, which must == the displayer field initialized in the constructor

uninstallUI

public final void uninstallUI(JComponent c)
This method is final. Subclasses which need to provide additional initialization should override uninstall()

Overrides:
uninstallUI in class ComponentUI
Parameters:
c - A JComponent, which must == the displayer field initialized in the constructor

install

protected void install()
Subclasses may override this method to do anything they need to do on installUI(). It will be called after listeners, the displayer, etc. (all pseudo-final protected fields) have been initialized.


uninstall

protected void uninstall()
Subclasses may override this method to do anything they need to do on uninstallUI(). It will be called before the protected fields of the instance have been nulled.


uichange

protected boolean uichange()
Description copied from class: TabbedContainerUI
This method is called if TabbedContainer.updateUI() gets called after a UI delegate has been installed (in other words, the user did something like switch look and feels or switch the Windows desktop theme).

Normally, the only UI delegate that exists for TabbedContainer is DefaultTabbedContainerUI, so it makes no sense to replace one with another, since they do the same thing.

However, this method can be used to update the tab displayer component's UI. Subclasses are expected to override this method to call updateUI() on the displayer, or do whatever is appropriate to ensure that the UI will look right after the change - or to return true from this method, in which the entire UI delegate for the tabbed container will be replaced.

Overrides:
uichange in class TabbedContainerUI
Returns:
false

installContentDisplayer

protected void installContentDisplayer()
Installs the content displayer component and its layout manager


installTabDisplayer

protected void installTabDisplayer()
Installs the tab displayer component into the container. By default, installs it using the constraint BorderLayout.NORTH.


installBorders

protected void installBorders()
Installs borders on the container, content displayer and tab displayer


installListeners

protected void installListeners()
Installs a component listener on the component. Listeners on the data model and selection model are installed when the component is shown, as detected by the component listener.


attachModelAndSelectionListeners

protected void attachModelAndSelectionListeners()
Begin listening to the model for changes in the selection, which should cause us to update the displayed component in the content contentDisplayer. Listening starts when the component is first shown, and stops when it is hidden; if you override createComponentListener(), you will need to call this method when the component is shown.


detachModelAndSelectionListeners

protected void detachModelAndSelectionListeners()
Stop listening to the model for changes in the selection, which should cause us to update the displayed component in the content contentDisplayer, and changes in the data model which can affect the displayed component. Listening starts when the component is first shown, and stops when it is hidden; if you override createComponentListener(), you will need to call this method when the component is hidden.


uninstallListeners

protected void uninstallListeners()
Uninstalls the component listener installed in installListeners()


uninstallDisplayers

protected void uninstallDisplayers()
Uninstalls and nulls references to the content contentDisplayer and tab contentDisplayer, and removes all components from the content contentDisplayer.


createTabDisplayer

protected TabDisplayer createTabDisplayer()
Create the component which will display the tabs.


createContentDisplayer

protected JPanel createContentDisplayer()
Create the component which will contain the content (the components which correspond to tabs). The default implementation simply returns a vanilla, unadorned JPanel.


createFxProvider

protected FxProvider createFxProvider()
Create an FxProvider instance which will provide transition effects when tabs are selected. By default creates a no-op instance for all displayer types except TYPE_SLIDING.

Returns:
An instance of FxProvider

createContentDisplayerLayout

protected LayoutManager createContentDisplayerLayout()
Creates the content contentDisplayer's layout manager, responsible for ensuring that the correct component is on top and is the only one showing


createLayout

protected LayoutManager createLayout()
Create the layout manager that will manage the layout of the TabbedContainer. A TabbedContainer contains two components - the tabs contentDisplayer, and the component contentDisplayer.

The layout manager determines the position of the tabs relative to the contentDisplayer component which displays the tab contents.

The default implementation uses BorderLayout. If you override this, you should probably override installDisplayer() as well.


createComponentListener

protected ComponentListener createComponentListener()
Create a component listener responsible for initializing the contentDisplayer component when the tabbed container is shown


createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener()
Create a property change listener which will update the tab displayer in accordance with property changes on the container. Currently the only property change of interest is calls to TabbedContainer.setActive(), which simply cause the active state to be set on the displayer.


ensureSelectedComponentIsShowing

protected void ensureSelectedComponentIsShowing()
Ensures that the component the selection model says is selected is the one that is showing.


toComp

protected final Component toComp(TabData data)
Convenience method for fetching a component from a TabData object via the container's ComponentConverter


showComponent

protected Component showComponent(Component c)
Shows the passed component. This method does not communicate with the data model in any way shape or form, it just moves the passed component to the front. It should only be called in response to an event from the data model or selection model.

If you override createContentDisplayerLayoutModel() to provide your own layout manager to arrange the displayed component, you need to override this to tell the layout (or do whatever is needed) to change the component that is shown.

Parameters:
c - The component to be shown
Returns:
The previously showing component, or null if no change was made

showComponentWithFxProvider

protected final void showComponentWithFxProvider(Component c)
Shows a component in the control, using the FxProvider created in createFxProvider() to manage showing it. Equivalent to calling showComponent, but there may be a delay while the effect is performed. If no FxProvider is installed, this will simply delegate to showComponent; if not, the FxProvider is expected to do that when its effect is completed.

Parameters:
c - The component to be shown.

initDisplayer

protected void initDisplayer()
Fills contentDisplayer container with components retrieved from model.


createModelListener

protected ComplexListDataListener createModelListener()
Create a listener for the TabDataModel. This listener is responsible for keeping the state of the contained components in the displayer in sync with the contents of the data model. Note that it is not necessary for this listener to adjust the selection - DefaultTabSelectionModel handles cases such as removing the selected component appropriately, so if such a model change happens, a selection change will be immediately forthcoming to handle it.

Note that it is important that this listener be added to the data model after the DefaultSelectionModel has added its listener. It is important to create the displayer component before adding this listener. Some support for privilged listeners may be added to DefaultTabDataModel in the future to avoid this issue entirely.


createSelectionListener

protected ChangeListener createSelectionListener()
Create a ChangeListener which will listen to the selection model of the tab displayer, and update the displayed component in the displayer when the selection model changes.


getTabRect

public Rectangle getTabRect(int tab,
                            Rectangle r)
Description copied from class: TabbedContainerUI
Get the bounds of a tab. Note that for non-rectangular tabs this may not correspond exactly to the area in which it will respond to mouse clicks.

Specified by:
getTabRect in class TabbedContainerUI
Parameters:
tab - A tab index
r - A rectangle to configure with the information, or null
Returns:
The passed rectangle, or a new one if null was passed

requestAttention

protected void requestAttention(int tab)
Specified by:
requestAttention in class TabbedContainerUI

cancelRequestAttention

protected void cancelRequestAttention(int tab)
Specified by:
cancelRequestAttention in class TabbedContainerUI

setShowCloseButton

public void setShowCloseButton(boolean val)
Specified by:
setShowCloseButton in class TabbedContainerUI

isShowCloseButton

public boolean isShowCloseButton()
Specified by:
isShowCloseButton in class TabbedContainerUI

updateOrientation

protected final void updateOrientation()
Checks the position of the tabbed container relative to its parent window, and potentially updates its orientation client property.

See Also:
TabDisplayer.PROP_ORIENTATION

tabForCoordinate

public int tabForCoordinate(Point p)
Description copied from class: TabbedContainerUI
Get the tab at a given point in the coordinate space of the container.

Specified by:
tabForCoordinate in class TabbedContainerUI
Parameters:
p - A point
Returns:
The tab index at this point, or -1 if no tab

makeTabVisible

public void makeTabVisible(int tab)
Description copied from class: TabbedContainerUI
Make a tab visible. No-op except in the case of scrolling tabs, in which case the tab may be scrolled offscreen.

Specified by:
makeTabVisible in class TabbedContainerUI
Parameters:
tab - A tab index

getSelectionModel

public SingleSelectionModel getSelectionModel()
Description copied from class: TabbedContainerUI
Get the selection model that tracks and determines which tab is selected.

Specified by:
getSelectionModel in class TabbedContainerUI
Returns:
The selection model (in the default implementation, this is the selection model of the embedded tab displayer)

createImageOfTab

public Image createImageOfTab(int idx)
Description copied from class: TabbedContainerUI
Create an image suitable for use in drag and drop operations, of a tab

Specified by:
createImageOfTab in class TabbedContainerUI

getExactTabIndication

public Polygon getExactTabIndication(int idx)
Description copied from class: TabbedContainerUI
Get a polygon matching the shape of the tab

Specified by:
getExactTabIndication in class TabbedContainerUI

getInsertTabIndication

public Polygon getInsertTabIndication(int idx)
Description copied from class: TabbedContainerUI
Get a polygon indicating the insertion of a tab before the passed index, unless the index is equal to the model size, in which case it will return an indication for inserting a tab at the end.

Specified by:
getInsertTabIndication in class TabbedContainerUI
Parameters:
idx - A tab index
Returns:
A shape representing the shape of the tab as it is displayed onscreen, in the coordinate space of the displayer

getContentArea

public Rectangle getContentArea()
Description copied from class: TabbedContainerUI
Get a rectangle matching the area in which content is displayed

Specified by:
getContentArea in class TabbedContainerUI

getTabsArea

public Rectangle getTabsArea()
Description copied from class: TabbedContainerUI
Get a rectangle matching the area in which tabs are displayed

Specified by:
getTabsArea in class TabbedContainerUI

dropIndexOfPoint

public int dropIndexOfPoint(Point p)
Description copied from class: TabbedContainerUI
Index at which a tab would be inserted if a suitable object were dropped at this point.

Specified by:
dropIndexOfPoint in class TabbedContainerUI
Parameters:
p - A point
Returns:
A tab index which may be equal to the size of the model (past the last tab index) if the tab should be inserted at the end.

getTabsArea

public Rectangle getTabsArea(Rectangle dest)

org.netbeans.swing.tabcontrol 1.8

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