The state of the horizontal and vertical scrollbars is represented
by two ScrollPaneAdjustable
objects (one for each
dimension) which implement the Adjustable
interface.
The API provides methods to access those objects such that the
attributes on the Adjustable object (such as unitIncrement, value,
etc.) can be manipulated.
Certain adjustable properties (minimum, maximum, blockIncrement, and visibleAmount) are set internally by the scrollpane in accordance with the geometry of the scrollpane and its child and these should not be set by programs using the scrollpane.
If the scrollbar display policy is defined as "never", then the scrollpane can still be programmatically scrolled using the setScrollPosition() method and the scrollpane will move and clip the child's contents appropriately. This policy is useful if the program needs to create and manage its own adjustable controls.
The placement of the scrollbars is controlled by platform-specific properties set by the user outside of the program.
The initial size of this container is set to 100x100, but can be reset using setSize().
Scrolling with the wheel on a wheel-equipped mouse is enabled by default.
This can be disabled using setWheelScrollingEnabled
.
Wheel scrolling can be customized by setting the block and
unit increment of the horizontal and vertical Adjustables.
For information on how mouse wheel events are dispatched, see
the class description for MouseWheelEvent
.
Insets are used to define any space used by scrollbars and any borders created by the scroll pane. getInsets() can be used to get the current value for the insets. If the value of scrollbarsAlwaysVisible is false, then the value of the insets will change dynamically depending on whether the scrollbars are currently visible or not.
Modifier and Type | Class and Description |
---|---|
protected class | ScrollPane.
This class implements accessibility support for the
|
pack-priv static class | ScrollPane.
Invoked when the value of the adjustable has changed. |
Modifier and Type | Field and Description |
---|---|
private static final String | |
private static final boolean | |
private ScrollPaneAdjustable | hAdjustable
An adjustable horizontal scrollbar. |
private static int | |
private int | scrollbarDisplayPolicy
There are 3 ways in which a scroll bar can be displayed. |
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. |
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. |
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. |
private static final long | serialVersionUID
Use serialVersionUID from JDK 1.1 for interoperability.
|
private ScrollPaneAdjustable | vAdjustable
An adjustable vertical scrollbar. |
private boolean | wheelScrollingEnabled
Indicates whether or not scrolling should take place when a MouseWheelEvent is received. |
Access | Constructor and Description |
---|---|
public | |
public | ScrollPane(int
policy for when scrollbars should be shown scrollbarDisplayPolicy)Create a new scrollpane container. |
Modifier and Type | Method and Description |
---|---|
protected final void | addImpl(Component
the component to be added comp, Object not applicable constraints, int position of child component (must be <= 0) index)Overrides java. |
public void | |
private void | |
pack-priv void | |
pack-priv Dimension | |
pack-priv String | constructComponentName()
Overrides java. |
public void | doLayout()
Overrides java. |
protected boolean | eventTypeEnabled(int type)
Overrides java. |
public AccessibleContext | Returns: an AccessibleAWTScrollPane that serves as the AccessibleContext of this ScrollPaneOverrides java. Implements javax. |
public Adjustable | Returns: the horizontal scrollbar stateReturns the |
public int | Returns: the height of a horizontal scrollbar in pixelsReturns 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. |
public int | Returns: the display policy for the scrollbarsReturns the display policy for the scrollbars. |
public Point | Returns: the coordinate position for the current scroll positionReturns the current x,y position within the child which is displayed at the 0,0 location of the scrolled panel's view port. |
public Adjustable | Returns: the vertical scrollbar stateReturns the |
public Dimension | Returns: the size of the view port in pixelsReturns the current size of the scroll pane's view port. |
public int | Returns: the width of a vertical scrollbar in pixelsReturns 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. |
private static native void | |
public boolean | Returns: true if the wheel scrolling enabled;
otherwise false Indicates whether or not scrolling will take place in response to the mouse wheel. |
public void | layout()
Overrides java.
Deprecated
As of JDK version 1.1,
replaced by
doLayout() .
|
public String | Returns: the parameter string of this scroll paneOverrides java. ScrollPane .
|
public void | printComponents(Graphics
the specified Graphics window g)Overrides java. |
protected void | processMouseWheelEvent(MouseWheelEvent
the mouse wheel event e)Overrides java. ScrollPane by scrolling an appropriate amount.
|
private void | readObject(ObjectInputStream
the s)
Reads default serializable fields to stream.
ObjectInputStream to read |
public final void | setLayout(LayoutManager
the specified layout manager mgr)Overrides java. |
public void | setScrollPosition(int
the x position to scroll to x, int the y position to scroll to y)Scrolls to the specified position within the child component. |
public void | setScrollPosition(Point
the Point representing the position to scroll to p)Scrolls to the specified position within the child component. |
public void | setWheelScrollingEnabled(boolean
true if scrolling should be done
automatically for a MouseWheelEvent,
false otherwise.Enables/disables scrolling in response to movement of the mouse wheel. |
private void | writeObject(ObjectOutputStream
the s)
Writes default serializable fields to stream.
ObjectOutputStream to write |
base | back to summary |
---|---|
private static final String base |
defaultWheelScroll | back to summary |
---|---|
private static final boolean defaultWheelScroll |
hAdjustable | back to summary |
---|---|
private ScrollPaneAdjustable hAdjustable An adjustable horizontal scrollbar.
It is important to note that you must NOT call 3
|
nameCounter | back to summary |
---|---|
private static int nameCounter |
scrollbarDisplayPolicy | back to summary |
---|---|
private int scrollbarDisplayPolicy There are 3 ways in which a scroll bar can be displayed. This integer will represent one of these 3 displays - (SCROLLBARS_ALWAYS, SCROLLBARS_AS_NEEDED, SCROLLBARS_NEVER)
|
SCROLLBARS_ALWAYS | back to summary |
---|---|
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_AS_NEEDED | back to summary |
---|---|
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_NEVER | back to summary |
---|---|
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. |
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID Hides java. Use serialVersionUID from JDK 1.1 for interoperability. |
vAdjustable | back to summary |
---|---|
private ScrollPaneAdjustable vAdjustable An adjustable vertical scrollbar.
It is important to note that you must NOT call 3
|
wheelScrollingEnabled | back to summary |
---|---|
private boolean wheelScrollingEnabled Indicates whether or not scrolling should take place when a MouseWheelEvent is received.
|
ScrollPane | back to summary |
---|---|
public ScrollPane() throws HeadlessException Create a new scrollpane container with a scrollbar display policy of "as needed".
|
ScrollPane | back to summary |
---|---|
public ScrollPane(int scrollbarDisplayPolicy) throws HeadlessException Create a new scrollpane container.
|
addImpl | back to summary |
---|---|
protected final void addImpl(Component comp, Object constraints, int index) Overrides java. 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. |
addNotify | back to summary |
---|---|
public void addNotify() Overrides java. Creates the scroll pane's peer. |
addToPanel | back to summary |
---|---|
private void addToPanel(Component comp, Object constraints, int index) |
autoProcessMouseWheel | back to summary |
---|---|
pack-priv void autoProcessMouseWheel(MouseWheelEvent e) Overrides java. |
calculateChildSize | back to summary |
---|---|
pack-priv Dimension calculateChildSize() Determine the size to allocate the child component. If the viewport area is bigger than the preferred size of the child then the child is allocated enough to fill the viewport, otherwise the child is given it's preferred size. |
constructComponentName | back to summary |
---|---|
pack-priv String constructComponentName() Overrides java. Construct a name for this component. Called by getName() when the name is null. |
doLayout | back to summary |
---|---|
public void doLayout() Overrides java. 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.
|
eventTypeEnabled | back to summary |
---|---|
protected boolean eventTypeEnabled(int type) Overrides java. If wheel scrolling is enabled, we return true for MouseWheelEvents
|
getAccessibleContext | back to summary |
---|---|
public AccessibleContext getAccessibleContext() Overrides java. Implements javax. Gets the AccessibleContext associated with this ScrollPane. For scroll panes, the AccessibleContext takes the form of an AccessibleAWTScrollPane. A new AccessibleAWTScrollPane instance is created if necessary.
|
getHAdjustable | back to summary |
---|---|
public Adjustable getHAdjustable() Returns the
|
getHScrollbarHeight | back to summary |
---|---|
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.
|
getScrollbarDisplayPolicy | back to summary |
---|---|
public int getScrollbarDisplayPolicy() Returns the display policy for the scrollbars.
|
getScrollPosition | back to summary |
---|---|
public 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. This is a convenience method which interfaces with the adjustable objects which represent the state of the scrollbars.
|
getVAdjustable | back to summary |
---|---|
public Adjustable getVAdjustable() Returns the
|
getViewportSize | back to summary |
---|---|
public Dimension getViewportSize() Returns the current size of the scroll pane's view port.
|
getVScrollbarWidth | back to summary |
---|---|
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.
|
initIDs | back to summary |
---|---|
private static native void initIDs() Hides java. Initialize JNI field and method IDs |
isWheelScrollingEnabled | back to summary |
---|---|
public boolean isWheelScrollingEnabled() Indicates whether or not scrolling will take place in response to the mouse wheel. Wheel scrolling is enabled by default.
|
layout | back to summary |
---|---|
public void layout() Overrides java. Deprecated As of JDK version 1.1,
replaced by
|
paramString | back to summary |
---|---|
public String paramString() Overrides java. Returns a string representing the state of this
|
printComponents | back to summary |
---|---|
public void printComponents(Graphics g) Overrides java. Prints the component in this scroll pane.
|
processMouseWheelEvent | back to summary |
---|---|
protected void processMouseWheelEvent(MouseWheelEvent e) Overrides java. Process mouse wheel events that are delivered to this
Note that if the event parameter is
|
readObject | back to summary |
---|---|
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException, HeadlessException Hides java. Reads default serializable fields to stream.
|
setLayout | back to summary |
---|---|
public final void setLayout(LayoutManager mgr) Overrides java. Sets the layout manager for this container. This method is overridden to prevent the layout mgr from being set.
|
setScrollPosition | back to summary |
---|---|
public void setScrollPosition(int x, int y) Scrolls to the specified position within the child component. A call to this method is only valid if the scroll pane contains a child. Specifying a position outside of the legal scrolling bounds of the child will scroll to the closest legal position. Legal bounds are defined to be the rectangle: x = 0, y = 0, width = (child width - view port width), height = (child height - view port height). This is a convenience method which interfaces with the Adjustable objects which represent the state of the scrollbars.
|
setScrollPosition | back to summary |
---|---|
public void setScrollPosition(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 and the specified position is within legal scrolling bounds of the child. Specifying a position outside of the legal scrolling bounds of the child will scroll to the closest legal position. Legal bounds are defined to be the rectangle: x = 0, y = 0, width = (child width - view port width), height = (child height - view port height). This is a convenience method which interfaces with the Adjustable objects which represent the state of the scrollbars.
|
setWheelScrollingEnabled | back to summary |
---|---|
public void setWheelScrollingEnabled(boolean handleWheel) Enables/disables scrolling in response to movement of the mouse wheel. Wheel scrolling is enabled by default.
|
writeObject | back to summary |
---|---|
private void writeObject(ObjectOutputStream s) throws IOException Hides java. Writes default serializable fields to stream.
|
ScrollPane
class. It provides an implementation of the
Java Accessibility API appropriate to scroll pane user-interface
elements.
Modifier and Type | Field and Description |
---|---|
private static final long | serialVersionUID
Hides java. |
Access | Constructor and Description |
---|---|
protected |
Modifier and Type | Method and Description |
---|---|
public AccessibleRole | Returns: an instance of AccessibleRole describing the role of the objectOverrides java. |
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID Hides java. Use serialVersionUID from JDK 1.3 for interoperability. |
AccessibleAWTScrollPane | back to summary |
---|---|
protected AccessibleAWTScrollPane() Constructs an |
getAccessibleRole | back to summary |
---|---|
public AccessibleRole getAccessibleRole() Overrides java. Get the role of this object.
|
Modifier and Type | Field and Description |
---|---|
private final ScrollPane | |
private static final long | serialVersionUID
Use serialVersionUID from JDK 1.1.1 for interoperability. |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
public void | adjustmentValueChanged(AdjustmentEvent
the event to be processed e)Implements java. |
scroller | back to summary |
---|---|
private final ScrollPane scroller |
serialVersionUID | back to summary |
---|---|
private static final long serialVersionUID Use serialVersionUID from JDK 1.1.1 for interoperability. |
PeerFixer | back to summary |
---|---|
pack-priv PeerFixer(ScrollPane scroller) |
adjustmentValueChanged | back to summary |
---|---|
public void adjustmentValueChanged(AdjustmentEvent e) Implements java. Invoked when the value of the adjustable has changed.
|