javax.swing.plaf.basic
Class BasicScrollPaneUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.ScrollPaneUI
          extended by javax.swing.plaf.basic.BasicScrollPaneUI
All Implemented Interfaces:
ScrollPaneConstants
Direct Known Subclasses:
MetalScrollPaneUI

public class BasicScrollPaneUI
extends ScrollPaneUI
implements ScrollPaneConstants

A UI delegate for the JScrollPane component.


Nested Class Summary
 class BasicScrollPaneUI.HSBChangeListener
          Listens for changes in the state of the horizontal scrollbar's model and updates the scrollpane accordingly.
protected  class BasicScrollPaneUI.MouseWheelHandler
          Listens for mouse wheel events and update the scrollpane accordingly.
 class BasicScrollPaneUI.PropertyChangeHandler
          Listens for property changes on the scrollpane and update the view accordingly.
 class BasicScrollPaneUI.ViewportChangeHandler
          Listens for changes of the viewport's extent size and updates the scrollpane accordingly.
 class BasicScrollPaneUI.VSBChangeListener
          Listens for changes in the state of the vertical scrollbar's model and updates the scrollpane accordingly.
 
Field Summary
protected  ChangeListener hsbChangeListener
          The horizontal scrollbar listener.
protected  JScrollPane scrollpane
          The Scrollpane for which the UI is provided by this class.
protected  PropertyChangeListener spPropertyChangeListener
          The scrollpane property change listener.
protected  ChangeListener viewportChangeListener
          The viewport listener.
protected  ChangeListener vsbChangeListener
          The vertical scrollbar listener.
 
Fields inherited from interface javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Constructor Summary
BasicScrollPaneUI()
           
 
Method Summary
protected  ChangeListener createHSBChangeListener()
          Creates and returns the change listener for the horizontal scrollbar.
protected  MouseWheelListener createMouseWheelListener()
          Creates and returns the mouse wheel listener for the scrollpane.
protected  PropertyChangeListener createPropertyChangeListener()
          Creates and returns the property change listener for the scrollpane.
static ComponentUI createUI(JComponent c)
           
protected  ChangeListener createViewportChangeListener()
          Creates and returns the change listener for the viewport.
protected  ChangeListener createVSBChangeListener()
          Creates and returns the change listener for the vertical scrollbar.
 Dimension getMinimumSize(JComponent c)
          Determines the minimum size of a component.
protected  void installDefaults(JScrollPane p)
           
protected  void installKeyboardActions(JScrollPane sp)
          Installs additional keyboard actions on the scrollpane.
protected  void installListeners(JScrollPane sp)
          Installs the listeners on the scrollbars, the viewport and the scrollpane.
 void installUI(JComponent c)
          Sets up the specified component so it conforms the the design guidelines of the implemented look and feel.
 void paint(Graphics g, JComponent c)
          Paints the component according to the design guidelines of the look and feel.
protected  void syncScrollPaneWithViewport()
          Synchronizes the scrollbar and header settings positions and extent with the viewport's view position and extent.
protected  void uninstallDefaults(JScrollPane p)
           
protected  void uninstallKeyboardActions(JScrollPane sp)
          Uninstalls all keyboard actions from the JScrollPane that have been installed by installKeyboardActions(javax.swing.JScrollPane).
protected  void uninstallListeners(JComponent c)
          Uninstalls all the listeners that have been installed in installListeners(JScrollPane).
 void uninstallUI(JComponent c)
          Puts the specified component into the state it had before ComponentUI.installUI(javax.swing.JComponent) was called.
protected  void updateColumnHeader(PropertyChangeEvent ev)
          Receives notification when the columnHeader property has changed on the scrollpane.
protected  void updateRowHeader(PropertyChangeEvent ev)
          Receives notification when the rowHeader property has changed on the scrollpane.
protected  void updateScrollBarDisplayPolicy(PropertyChangeEvent ev)
          Receives notification when the scrollBarDisplayPolicy property has changed on the scrollpane.
protected  void updateViewport(PropertyChangeEvent ev)
          Receives notification when the viewport property has changed on the scrollpane.
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getPreferredSize, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scrollpane

protected JScrollPane scrollpane
The Scrollpane for which the UI is provided by this class.


hsbChangeListener

protected ChangeListener hsbChangeListener
The horizontal scrollbar listener.


vsbChangeListener

protected ChangeListener vsbChangeListener
The vertical scrollbar listener.


viewportChangeListener

protected ChangeListener viewportChangeListener
The viewport listener.


spPropertyChangeListener

protected PropertyChangeListener spPropertyChangeListener
The scrollpane property change listener.

Constructor Detail

BasicScrollPaneUI

public BasicScrollPaneUI()
Method Detail

createUI

public static ComponentUI createUI(JComponent c)

installDefaults

protected void installDefaults(JScrollPane p)

uninstallDefaults

protected void uninstallDefaults(JScrollPane p)

installUI

public void installUI(JComponent c)
Description copied from class: ComponentUI
Sets up the specified component so it conforms the the design guidelines of the implemented look and feel. When the look and feel changes, a ComponentUI delegate is created. The delegate object then receives an installUI message.

This method should perform the following tasks:

Overrides:
installUI in class ComponentUI
Parameters:
c - the component for which this delegate will provide services.
See Also:
ComponentUI.uninstallUI(javax.swing.JComponent), JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()

installListeners

protected void installListeners(JScrollPane sp)
Installs the listeners on the scrollbars, the viewport and the scrollpane.

Parameters:
sp - the scrollpane on which to install the listeners

installKeyboardActions

protected void installKeyboardActions(JScrollPane sp)
Installs additional keyboard actions on the scrollpane. This is a hook method provided to subclasses in order to install their own keyboard actions.

Parameters:
sp - the scrollpane to install keyboard actions on

uninstallKeyboardActions

protected void uninstallKeyboardActions(JScrollPane sp)
Uninstalls all keyboard actions from the JScrollPane that have been installed by installKeyboardActions(javax.swing.JScrollPane). This is a hook method provided to subclasses to add their own keyboard actions.

Parameters:
sp - the scrollpane to uninstall keyboard actions from

createHSBChangeListener

protected ChangeListener createHSBChangeListener()
Creates and returns the change listener for the horizontal scrollbar.

Returns:
the change listener for the horizontal scrollbar

createVSBChangeListener

protected ChangeListener createVSBChangeListener()
Creates and returns the change listener for the vertical scrollbar.

Returns:
the change listener for the vertical scrollbar

createViewportChangeListener

protected ChangeListener createViewportChangeListener()
Creates and returns the change listener for the viewport.

Returns:
the change listener for the viewport

createPropertyChangeListener

protected PropertyChangeListener createPropertyChangeListener()
Creates and returns the property change listener for the scrollpane.

Returns:
the property change listener for the scrollpane

createMouseWheelListener

protected MouseWheelListener createMouseWheelListener()
Creates and returns the mouse wheel listener for the scrollpane.

Returns:
the mouse wheel listener for the scrollpane
Since:
1.4

uninstallUI

public void uninstallUI(JComponent c)
Description copied from class: ComponentUI
Puts the specified component into the state it had before ComponentUI.installUI(javax.swing.JComponent) was called.

Overrides:
uninstallUI in class ComponentUI
Parameters:
c - the component for which this delegate has provided services.
See Also:
ComponentUI.installUI(javax.swing.JComponent), JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()

uninstallListeners

protected void uninstallListeners(JComponent c)
Uninstalls all the listeners that have been installed in installListeners(JScrollPane).

Parameters:
c - the scrollpane from which to uninstall the listeners

getMinimumSize

public Dimension getMinimumSize(JComponent c)
Description copied from class: ComponentUI
Determines the minimum size of a component. The default implementation calls ComponentUI.getPreferredSize(javax.swing.JComponent), but subclasses might want to override this.

Overrides:
getMinimumSize in class ComponentUI
Parameters:
c - the component for which this delegate performs services.
Returns:
the minimum size, or null to indicate that c’s layout manager should be asked to calculate the minimum size.

paint

public void paint(Graphics g,
                  JComponent c)
Description copied from class: ComponentUI
Paints the component according to the design guidelines of the look and feel. Most subclasses will want to override this method.

Overrides:
paint in class ComponentUI
Parameters:
g - the graphics for painting.
c - the component for which this delegate performs services.

syncScrollPaneWithViewport

protected void syncScrollPaneWithViewport()
Synchronizes the scrollbar and header settings positions and extent with the viewport's view position and extent.


updateColumnHeader

protected void updateColumnHeader(PropertyChangeEvent ev)
Receives notification when the columnHeader property has changed on the scrollpane.

Parameters:
ev - the property change event

updateRowHeader

protected void updateRowHeader(PropertyChangeEvent ev)
Receives notification when the rowHeader property has changed on the scrollpane.

Parameters:
ev - the property change event

updateScrollBarDisplayPolicy

protected void updateScrollBarDisplayPolicy(PropertyChangeEvent ev)
Receives notification when the scrollBarDisplayPolicy property has changed on the scrollpane.

Parameters:
ev - the property change event

updateViewport

protected void updateViewport(PropertyChangeEvent ev)
Receives notification when the viewport property has changed on the scrollpane. This method sets removes the viewportChangeListener from the old viewport and adds it to the new viewport.

Parameters:
ev - the property change event