dog.gui
Class DScrollPane

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--dog.gui.DContainer
                    |
                    +--dog.gui.DScrollPane
All Implemented Interfaces:
java.awt.event.AdjustmentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, Referential, java.io.Serializable

public class DScrollPane
extends DContainer
implements java.awt.event.AdjustmentListener

A container class which implements automatic horizontal and/or vertical scrolling for a single child component. The display policy for the scrollbars can be set to:

  1. as needed: scrollbars created and shown only when needed by scrollpane
  2. always: scrollbars created and always shown by the scrollpane
  3. never: scrollbars never created or shown by the scrollpane

See Also:
Serialized Form

Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
protected  int policy
          The scrollbar display policy.
static int SCROLLBARS_ALWAYS
          Specifies that horizontal/vertical scrollbars should always be shown regardless of the respective sizes of the scrollpane and child.
static int SCROLLBARS_AS_NEEDED
          Specifies that horizontal/vertical scrollbar should be shown only when the size of the child exceeds the size of the scrollpane in the horizontal/vertical dimension.
static int SCROLLBARS_NEVER
          Specifies that horizontal/vertical scrollbars should never be shown regardless of the respective sizes of the scrollpane and child.
 
Fields inherited from class dog.gui.DContainer
cancelButton, CENTER, defaultButton, EAST, NORTH, NORTHEAST, NORTHWEST, reference, SOUTH, SOUTHEAST, SOUTHWEST, tooltip, WEST
 
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
DScrollPane()
          Create a new scrollpane container with an as-needed scrollbar display policy.
DScrollPane(int policy)
          Create a new scrollpane container.
 
Method Summary
protected  void addImpl(java.awt.Component comp, java.lang.Object constraints, int index)
          Adds the specified component to this scroll pane container.
 void adjustmentValueChanged(java.awt.event.AdjustmentEvent event)
          A scrollbar was moved.
 void doLayout()
          Lays out this container by resizing its child to its preferred size.
 java.awt.Adjustable getHAdjustable()
          Returns the Adjustable object which represents the state of the horizontal scrollbar.
 int getHScrollbarHeight()
          Returns the height that would be occupied by a horizontal scrollbar, which is independent of whether it is currently displayed by the scroll pane or not.
 int getPolicy()
          Returns the display policy for the scrollbars.
 java.awt.Dimension getPreferredSize()
           
 java.awt.Point getScrollPosition()
          Returns the current x,y position within the child which is displayed at the 0,0 location of the scrolled panel's view port.
 java.awt.Adjustable getVAdjustable()
          Returns the Adjustable object which represents the state of the vertical scrollbar.
 java.awt.Dimension getViewportSize()
          Returns the current size of the scroll pane's view port.
 int getVScrollbarWidth()
          Returns the width that would be occupied by a vertical scrollbar, which is independent of whether it is currently displayed by the scroll pane or not.
 void paint(java.awt.Graphics g)
           
 java.lang.String paramString()
          Returns a parameter string for this component.
 void setLayout(java.awt.LayoutManager mgr)
          Overrides setting the layout manager for this container, as this is controlled by the scrollpane.
 void setScrollPosition(int x, int y)
          Scrolls to the specified position within the view.
 void setScrollPosition(java.awt.Point p)
          Scrolls to the specified position within the child component.
 
Methods inherited from class dog.gui.DContainer
addPropertyChangeListener, alignParamString, drawActiveButtonBorder, drawActiveOptionBorder, drawArrow, drawBorder, drawButtonBorder, drawCheckbox, drawDarkBorder, drawDefaultButtonBorder, drawDisabledBorder, drawDisabledCheckbox, drawDisabledOption, drawExpander, drawFocusBorder, drawImage, drawLabel, drawOption, drawOptionBorder, drawPressedBorder, getCancelButton, getComponent, getDefaultButton, getDefaultToolkit, getImage, getImage, getImage, getReference, getRootPane, getTooltip, isPreloadImages, processCancelAction, processDefaultAction, processEvent, processMouseEvent, processMouseMotionEvent, removePropertyChangeListener, setCancelButton, setDefaultButton, setEnabled, setPreloadImages, setReference, setTooltip, toString
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addNotify, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SCROLLBARS_AS_NEEDED

public static final int SCROLLBARS_AS_NEEDED
Specifies that horizontal/vertical scrollbar should be shown only when the size of the child exceeds the size of the scrollpane in the horizontal/vertical dimension.

SCROLLBARS_ALWAYS

public static final int SCROLLBARS_ALWAYS
Specifies that horizontal/vertical scrollbars should always be shown regardless of the respective sizes of the scrollpane and child.

SCROLLBARS_NEVER

public static final int SCROLLBARS_NEVER
Specifies that horizontal/vertical scrollbars should never be shown regardless of the respective sizes of the scrollpane and child.

policy

protected int policy
The scrollbar display policy.
Constructor Detail

DScrollPane

public DScrollPane()
Create a new scrollpane container with an as-needed scrollbar display policy.

DScrollPane

public DScrollPane(int policy)
Create a new scrollpane container.
Parameters:
policy - policy for when scrollbars should be shown
Method Detail

addImpl

protected final void addImpl(java.awt.Component comp,
                             java.lang.Object constraints,
                             int index)
Adds the specified component to this scroll pane container. If the scroll pane has an existing child component, that component is removed and the new one is added.
Overrides:
addImpl in class DContainer
Parameters:
comp - the component to be added
constraints - not applicable
index - position of child component (must be <= 0)

getPolicy

public int getPolicy()
Returns the display policy for the scrollbars.
Returns:
the display policy for the scrollbars

getViewportSize

public java.awt.Dimension getViewportSize()
Returns the current size of the scroll pane's view port.
Returns:
the size of the view port in pixels

getHScrollbarHeight

public int getHScrollbarHeight()
Returns the height that would be occupied by a horizontal scrollbar, which is independent of whether it is currently displayed by the scroll pane or not.
Returns:
the height of a horizontal scrollbar in pixels

getVScrollbarWidth

public int getVScrollbarWidth()
Returns the width that would be occupied by a vertical scrollbar, which is independent of whether it is currently displayed by the scroll pane or not.
Returns:
the width of a vertical scrollbar in pixels

getVAdjustable

public java.awt.Adjustable getVAdjustable()
Returns the Adjustable object which represents the state of the vertical scrollbar. If the scrollbar display policy is "never", this method returns null.

getHAdjustable

public java.awt.Adjustable getHAdjustable()
Returns the Adjustable object which represents the state of the horizontal scrollbar. If the scrollbar display policy is "never", this method returns null.

setScrollPosition

public void setScrollPosition(int x,
                              int y)
Scrolls to the specified position within the view. A call to this method is only valid if the scroll pane contains a child.
Parameters:
x - the x position to scroll to
y - the y position to scroll to

setScrollPosition

public void setScrollPosition(java.awt.Point p)
Scrolls to the specified position within the child component. A call to this method is only valid if the scroll pane contains a child.
Parameters:
p - the Point representing the position to scroll to

getScrollPosition

public java.awt.Point getScrollPosition()
Returns the current x,y position within the child which is displayed at the 0,0 location of the scrolled panel's view port.
Returns:
the coordinate position for the current scroll position

setLayout

public final void setLayout(java.awt.LayoutManager mgr)
Overrides setting the layout manager for this container, as this is controlled by the scrollpane.
Overrides:
setLayout in class java.awt.Container
Parameters:
mgr - the specified layout manager

getPreferredSize

public java.awt.Dimension getPreferredSize()
Overrides:
getPreferredSize in class java.awt.Container

doLayout

public void doLayout()
Lays out this container by resizing its child to its preferred size. If the new preferred size of the child causes the current scroll position to be invalid, the scroll position is set to the closest valid position.
Overrides:
doLayout in class java.awt.Container
See Also:
Component.validate()

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class java.awt.Container

adjustmentValueChanged

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent event)
A scrollbar was moved.
Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener

paramString

public java.lang.String paramString()
Returns a parameter string for this component.
Overrides:
paramString in class DContainer