public class

BasicScrollPaneUI

extends ScrollPaneUI
implements ScrollPaneConstants
java.lang.Object
   ↳ javax.swing.plaf.ComponentUI
     ↳ javax.swing.plaf.ScrollPaneUI
       ↳ javax.swing.plaf.basic.BasicScrollPaneUI
Known Direct Subclasses

Class Overview

A default L&F implementation of ScrollPaneUI.

Summary

Nested Classes
class BasicScrollPaneUI.HSBChangeListener Horizontal scrollbar listener. 
class BasicScrollPaneUI.MouseWheelHandler MouseWheelHandler is an inner class which implements the MouseWheelListener interface. 
class BasicScrollPaneUI.PropertyChangeHandler  
class BasicScrollPaneUI.VSBChangeListener Vertical scrollbar listener. 
class BasicScrollPaneUI.ViewportChangeHandler Listener for viewport events. 
[Expand]
Inherited Constants
From interface javax.swing.ScrollPaneConstants
Fields
protected ChangeListener hsbChangeListener
protected JScrollPane scrollpane
protected PropertyChangeListener spPropertyChangeListener
protected ChangeListener viewportChangeListener
protected ChangeListener vsbChangeListener
Public Constructors
BasicScrollPaneUI()
Public Methods
static ComponentUI createUI(JComponent x)
int getBaseline(JComponent c, int width, int height)
Returns the baseline.
Component.BaselineResizeBehavior getBaselineResizeBehavior(JComponent c)
Returns an enum indicating how the baseline of the component changes as the size changes.
Dimension getMaximumSize(JComponent c)
Returns the specified component's maximum size appropriate for the look and feel.
void installUI(JComponent x)
Configures the specified component appropriate for the look and feel.
void paint(Graphics g, JComponent c)
Paints the specified component appropriate for the look and feel.
void uninstallUI(JComponent c)
Reverses configuration which was done on the specified component during installUI.
Protected Methods
ChangeListener createHSBChangeListener()
MouseWheelListener createMouseWheelListener()
Creates an instance of MouseWheelListener, which is added to the JScrollPane by installUI().
PropertyChangeListener createPropertyChangeListener()
Creates an instance of PropertyChangeListener that's added to the JScrollPane by installUI().
ChangeListener createVSBChangeListener()
ChangeListener createViewportChangeListener()
void installDefaults(JScrollPane scrollpane)
void installKeyboardActions(JScrollPane c)
void installListeners(JScrollPane c)
void syncScrollPaneWithViewport()
void uninstallDefaults(JScrollPane c)
void uninstallKeyboardActions(JScrollPane c)
void uninstallListeners(JComponent c)
void updateColumnHeader(PropertyChangeEvent e)
void updateRowHeader(PropertyChangeEvent e)
void updateScrollBarDisplayPolicy(PropertyChangeEvent e)
void updateViewport(PropertyChangeEvent e)
[Expand]
Inherited Methods
From class javax.swing.plaf.ComponentUI
From class java.lang.Object

Fields

protected ChangeListener hsbChangeListener

protected JScrollPane scrollpane

protected PropertyChangeListener spPropertyChangeListener

protected ChangeListener viewportChangeListener

protected ChangeListener vsbChangeListener

Public Constructors

public BasicScrollPaneUI ()

Public Methods

public static ComponentUI createUI (JComponent x)

public int getBaseline (JComponent c, int width, int height)

Returns the baseline.

Parameters
c JComponent baseline is being requested for
width the width to get the baseline for
height the height to get the baseline for
Returns
  • baseline or a value < 0 indicating there is no reasonable baseline

public Component.BaselineResizeBehavior getBaselineResizeBehavior (JComponent c)

Returns an enum indicating how the baseline of the component changes as the size changes.

Parameters
c JComponent to return baseline resize behavior for
Returns
  • an enum indicating how the baseline changes as the component size changes

public Dimension getMaximumSize (JComponent c)

Returns the specified component's maximum size appropriate for the look and feel. If null is returned, the maximum size will be calculated by the component's layout manager instead (this is the preferred approach for any component with a specific layout manager installed). The default implementation of this method invokes getPreferredSize and returns that value.

Parameters
c the component whose maximum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
Returns
  • new Dimension(Short.MAX_VALUE, Short.MAX_VALUE)

public void installUI (JComponent x)

Configures the specified component appropriate for the look and feel. This method is invoked when the ComponentUI instance is being installed as the UI delegate on the specified component. This method should completely configure the component for the look and feel, including the following:

  1. Install any default property values for color, fonts, borders, icons, opacity, etc. on the component. Whenever possible, property values initialized by the client program should not be overridden.
  2. Install a LayoutManager on the component if necessary.
  3. Create/add any required sub-components to the component.
  4. Create/install event listeners on the component.
  5. Create/install a PropertyChangeListener on the component in order to detect and respond to component property changes appropriately.
  6. Install keyboard UI (mnemonics, traversal, etc.) on the component.
  7. Initialize any appropriate instance data.

Parameters
x the component where this UI delegate is being installed

public void paint (Graphics g, JComponent c)

Paints the specified component appropriate for the look and feel. This method is invoked from the ComponentUI.update method when the specified component is being painted. Subclasses should override this method and use the specified Graphics object to render the content of the component.

Parameters
g the Graphics context in which to paint
c the component being painted; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components

public void uninstallUI (JComponent c)

Reverses configuration which was done on the specified component during installUI. This method is invoked when this UIComponent instance is being removed as the UI delegate for the specified component. This method should undo the configuration performed in installUI, being careful to leave the JComponent instance in a clean state (no extraneous listeners, look-and-feel-specific property objects, etc.). This should include the following:

  1. Remove any UI-set borders from the component.
  2. Remove any UI-set layout managers on the component.
  3. Remove any UI-added sub-components from the component.
  4. Remove any UI-added event/property listeners from the component.
  5. Remove any UI-installed keyboard UI from the component.
  6. Nullify any allocated instance data objects to allow for GC.

Parameters
c the component from which this UI delegate is being removed; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components

Protected Methods

protected ChangeListener createHSBChangeListener ()

protected MouseWheelListener createMouseWheelListener ()

Creates an instance of MouseWheelListener, which is added to the JScrollPane by installUI(). The returned MouseWheelListener is used to handle mouse wheel-driven scrolling.

Returns
  • MouseWheelListener which implements wheel-driven scrolling

protected PropertyChangeListener createPropertyChangeListener ()

Creates an instance of PropertyChangeListener that's added to the JScrollPane by installUI(). Subclasses can override this method to return a custom PropertyChangeListener, e.g.

 class MyScrollPaneUI extends BasicScrollPaneUI {
    protected PropertyChangeListener createPropertyChangeListener() {
        return new MyPropertyChangeListener();
    }
    public class MyPropertyChangeListener extends PropertyChangeListener {
        public void propertyChange(PropertyChangeEvent e) {
            if (e.getPropertyName().equals("viewport")) {
                // do some extra work when the viewport changes
            }
            super.propertyChange(e);
        }
    }
 }
 

protected ChangeListener createVSBChangeListener ()

protected ChangeListener createViewportChangeListener ()

protected void installDefaults (JScrollPane scrollpane)

protected void installKeyboardActions (JScrollPane c)

protected void installListeners (JScrollPane c)

protected void syncScrollPaneWithViewport ()

protected void uninstallDefaults (JScrollPane c)

protected void uninstallKeyboardActions (JScrollPane c)

protected void uninstallListeners (JComponent c)

protected void updateColumnHeader (PropertyChangeEvent e)

protected void updateRowHeader (PropertyChangeEvent e)

protected void updateScrollBarDisplayPolicy (PropertyChangeEvent e)

protected void updateViewport (PropertyChangeEvent e)