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

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

org.netbeans.swing.tabcontrol 1.8

org.netbeans.swing.tabcontrol.plaf
Class AbstractTabDisplayerUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by org.netbeans.swing.tabcontrol.TabDisplayerUI
          extended by org.netbeans.swing.tabcontrol.plaf.AbstractTabDisplayerUI
Direct Known Subclasses:
BasicSlidingTabDisplayerUI, BasicTabDisplayerUI, ToolbarTabDisplayerUI

public abstract class AbstractTabDisplayerUI
extends TabDisplayerUI

Base class for the implementations of TabDisplayerUI in this package. Uses TabLayoutModel for managing the layout of the tabs. Defines an SPI for UI delegates for TabDisplayer.

For most use cases, it will make more sense to subclass BasicTabDisplayerUI or BasicScrollingTabDisplayerUI, which handle most of the logic any implementation will need.

See Also:
BasicTabDisplayerUI, BasicScrollingTabDisplayerUI

Nested Class Summary
protected  class AbstractTabDisplayerUI.DisplayerHierarchyListener
          A hierarchy listener which registers the component with ToolTipManager when displayed, and de-registers it when hidden
protected  class AbstractTabDisplayerUI.DisplayerPropertyChangeListener
          A property change listener which will repaint the selected tab when the "active" property changes on the tab displayer
protected  class AbstractTabDisplayerUI.ModelListener
          Simple implementation of a listener on a TabDataModel.
 
Field Summary
protected  ComponentListener componentListener
          Component listener - mainly used to detach listeners when the component is hidden, and reattach them when it is shown.
protected  HierarchyListener hierarchyListener
           
protected  TabLayoutModel layoutModel
          Layout model, which will be initialized in installUI() by calling createLayoutModel.
protected  AbstractTabDisplayerUI.ModelListener modelListener
          Listener on the TabDataModel.
protected  MouseListener mouseListener
          Mouse listener (which may optionally implement MouseWheelListener and MouseMotionListener), which handles mouse events over the tab, triggering selection model changes, repaints, etc.
protected  PropertyChangeListener propertyChangeListener
          A property change listener to listen on any changes from the component which should trigger repainting or other operations.
protected  ChangeListener selectionListener
          A change listener which listens on the selection model and repaints as needed when the selection changes.
 
Fields inherited from class org.netbeans.swing.tabcontrol.TabDisplayerUI
displayer, selectionModel
 
Constructor Summary
AbstractTabDisplayerUI(TabDisplayer displayer)
          Creates a new instance of AbstractTabDisplayerUI
 
Method Summary
protected  ComponentListener createComponentListener()
          Create a ComponentListener that may be needed to handle resize, show, hide, etc.
protected  Font createFont()
           
protected  HierarchyListener createHierarchyListener()
           
protected abstract  TabLayoutModel createLayoutModel()
          Create an instance of TabLayoutModel which will provide coordinates for tabs
protected  AbstractTabDisplayerUI.ModelListener createModelListener()
          Create a listener on the data model that triggers repaints on appropriate changes.
protected abstract  MouseListener createMouseListener()
          Create the mouse listener that will be responsible for changing the selection on mouse events, triggering repaints on mouse enter/exit/motion, etc.
protected  PropertyChangeListener createPropertyChangeListener()
          Create a PropertyChangeListener which listens on any interesting properties of the control
protected abstract  ChangeListener createSelectionListener()
          Create a ChangeListener to be attached to the selection model.
protected  SingleSelectionModel createSelectionModel()
          Creates an instance of DefaultTabSelectionModel
 int dropIndexOfPoint(Point p)
          A very basic implementation of dropIndexOfPoint, which simply iterates all of the tab rectangles to see if they contain the point.
protected  void install()
          Called after creating the layout model, selection model and mouse listener, but before installing the mouse listener and selection model.
protected  void installListeners()
          Installs the mouse listener returned by createMouseListener into the control.
 void installUI(JComponent c)
          installUI is final to ensure listeners, etc.
protected  void modelChanged()
          Convenience method called by ModelListener.stateChanged() when the data model changes.
 void registerShortcuts(JComponent comp)
          Does nothing, no shortcuts
protected  Point toDropPoint(Point location)
          Converts a point into a point in the coordinate space of the tabs area, for determining what index a drop operation should affect.
protected  void uninstall()
          Called after uninstalling the mouse listener and selection model, but before references to that or the layout model or displayer have been nulled.
protected  void uninstallListeners()
          Installs the mouse listener returned by createMouseListener into the control.
 void uninstallUI(JComponent c)
          This method is final - subclasses that need to deinitialize should override uninstall(), and remove any listeners, null any unneeded references, etc.
 void unregisterShortcuts(JComponent comp)
          Does nothing, no shortcuts
 
Methods inherited from class org.netbeans.swing.tabcontrol.TabDisplayerUI
cancelRequestAttention, createImageOfTab, getButtonIcon, getExactTabIndication, getInsertTabIndication, getTabRect, makeTabVisible, postTabAction, requestAttention, shouldPerformAction, tabForCoordinate
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, createUI, 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

layoutModel

protected TabLayoutModel layoutModel
Layout model, which will be initialized in installUI() by calling createLayoutModel. The layout model provides tab coordinates.


mouseListener

protected MouseListener mouseListener
Mouse listener (which may optionally implement MouseWheelListener and MouseMotionListener), which handles mouse events over the tab, triggering selection model changes, repaints, etc.


componentListener

protected ComponentListener componentListener
Component listener - mainly used to detach listeners when the component is hidden, and reattach them when it is shown. Also used by BasicScrollingTabDisplayerUI to trigger re-layouts of scrolled tabs when the size of the component changes.


propertyChangeListener

protected PropertyChangeListener propertyChangeListener
A property change listener to listen on any changes from the component which should trigger repainting or other operations. The default implementation simply listens for changes in the active property to trigger a repaint.


modelListener

protected AbstractTabDisplayerUI.ModelListener modelListener
Listener on the TabDataModel. Responsible for repainting on model changes. Note that DefaultTabSelectionModel also listens on the model and automatically updates the selected index if, say, tabs are inserted before the currently selected tab.


selectionListener

protected ChangeListener selectionListener
A change listener which listens on the selection model and repaints as needed when the selection changes.


hierarchyListener

protected HierarchyListener hierarchyListener
Constructor Detail

AbstractTabDisplayerUI

public AbstractTabDisplayerUI(TabDisplayer displayer)
Creates a new instance of AbstractTabDisplayerUI

Method Detail

installUI

public final void installUI(JComponent c)
installUI is final to ensure listeners, etc. are created and attached. Subclasses that need to perform initialization on install should override install(), and refer to the displayer instance field, which will be initialized here.

Overrides:
installUI in class TabDisplayerUI
Parameters:
c - An instance of TabDisplayer

uninstallUI

public final void uninstallUI(JComponent c)
This method is final - subclasses that need to deinitialize should override uninstall(), and remove any listeners, null any unneeded references, etc.

Overrides:
uninstallUI in class TabDisplayerUI
Parameters:
c -

install

protected void install()
Called after creating the layout model, selection model and mouse listener, but before installing the mouse listener and selection model. Subclasses may use this method to do anything they need to do at ui install time.


uninstall

protected void uninstall()
Called after uninstalling the mouse listener and selection model, but before references to that or the layout model or displayer have been nulled. Subclasses may use this method to do any cleanup they need to do at uninstall time.


installListeners

protected final void installListeners()
Installs the mouse listener returned by createMouseListener into the control. If the mouse listener implements MouseMotionListener or MouseWheelListener, it will be installed as such as well.


uninstallListeners

protected final void uninstallListeners()
Installs the mouse listener returned by createMouseListener into the control. If the mouse listener implements MouseMotionListener or MouseWheelListener, it will be removed as such as well.


createHierarchyListener

protected HierarchyListener createHierarchyListener()

createLayoutModel

protected abstract TabLayoutModel createLayoutModel()
Create an instance of TabLayoutModel which will provide coordinates for tabs


createMouseListener

protected abstract MouseListener createMouseListener()
Create the mouse listener that will be responsible for changing the selection on mouse events, triggering repaints on mouse enter/exit/motion, etc. The installation code will detect if the resulting listener also implements MouseWheelListener or MouseMotionListener, and if so, will add it as such.

Returns:
A mouse listener, which may also implement MouseMotionListener and/or MouseWheelListener

createSelectionListener

protected abstract ChangeListener createSelectionListener()
Create a ChangeListener to be attached to the selection model. This listener will be responsible for repainting the appropriate areas on selection changes.

Returns:
A changeListener that will be notified of selection changes

createFont

protected Font createFont()

createModelListener

protected AbstractTabDisplayerUI.ModelListener createModelListener()
Create a listener on the data model that triggers repaints on appropriate changes.


createComponentListener

protected ComponentListener createComponentListener()
Create a ComponentListener that may be needed to handle resize, show, hide, etc. Returns null by default.


createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener()
Create a PropertyChangeListener which listens on any interesting properties of the control


createSelectionModel

protected SingleSelectionModel createSelectionModel()
Creates an instance of DefaultTabSelectionModel

Specified by:
createSelectionModel in class TabDisplayerUI

dropIndexOfPoint

public int dropIndexOfPoint(Point p)
A very basic implementation of dropIndexOfPoint, which simply iterates all of the tab rectangles to see if they contain the point. It is preferred to override this and provide a more efficient implementation unless the UI is not designed to display more than a few tabs.

Specified by:
dropIndexOfPoint in class TabDisplayerUI
Parameters:
p - A point
Returns:
The index, or -1 if none

modelChanged

protected void modelChanged()
Convenience method called by ModelListener.stateChanged() when the data model changes. Eliminates the need for custom subclasses where the only purpose is to discard some small amount of cached data. The default implementation simply calls displayer.repaint().


toDropPoint

protected Point toDropPoint(Point location)
Converts a point into a point in the coordinate space of the tabs area, for determining what index a drop operation should affect.

Parameters:
location - A point in the coordinate space of the container
Returns:
A point in the coordinate space of the tab display area

unregisterShortcuts

public void unregisterShortcuts(JComponent comp)
Does nothing, no shortcuts

Specified by:
unregisterShortcuts in class TabDisplayerUI

registerShortcuts

public void registerShortcuts(JComponent comp)
Does nothing, no shortcuts

Specified by:
registerShortcuts in class TabDisplayerUI

org.netbeans.swing.tabcontrol 1.8

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