java.lang.Object java.awt.Component java.awt.Container java.awt.ScrollPane
public class ScrollPane
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:
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.
static int
SCROLLBARS_ALWAYS
static int
SCROLLBARS_AS_NEEDED
static int
SCROLLBARS_NEVER
ScrollPane()
ScrollPane(int scrollbarDisplayPolicy)
protected void
addImpl(Component comp, Object constraints, int index)
void
addNotify()
void
doLayout()
protected boolean
eventTypeEnabled(int type)
AccessibleContext
getAccessibleContext()
Adjustable
getHAdjustable()
ScrollPaneAdjustable
object which represents the state of the horizontal scrollbar. int
getHScrollbarHeight()
int
getScrollbarDisplayPolicy()
Point
getScrollPosition()
Adjustable
getVAdjustable()
ScrollPaneAdjustable
object which represents the state of the vertical scrollbar. Dimension
getViewportSize()
int
getVScrollbarWidth()
boolean
isWheelScrollingEnabled()
void
layout()
doLayout()
. String
paramString()
ScrollPane
. void
printComponents(Graphics g)
protected void
processMouseWheelEvent(MouseWheelEvent e)
ScrollPane
by scrolling an appropriate amount. void
setLayout(LayoutManager mgr)
void
setScrollPosition(int x, int y)
void
setScrollPosition(Point p)
void
setWheelScrollingEnabled(boolean handleWheel)
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
Methods inherited from class java.awt.Component action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
SCROLLBARS_AS_NEEDED
public static final int SCROLLBARS_AS_NEEDED
public static final int SCROLLBARS_ALWAYS
public static final int SCROLLBARS_NEVER
public ScrollPane() throws HeadlessException
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true
GraphicsEnvironment.isHeadless()
public ScrollPane(int scrollbarDisplayPolicy) throws HeadlessException
scrollbarDisplayPolicy
- policy for when scrollbars should be shown
IllegalArgumentException
- if the specified scrollbar display policy is invalid
HeadlessException
- if GraphicsEnvironment.isHeadless() returns true
GraphicsEnvironment.isHeadless()
protected final void addImpl(Component comp, Object constraints, int index)
addImpl
in class Container
comp
- the component to be added
constraints
- not applicable
index
- position of child component (must be <= 0)
Container.add(Component)
, Container.add(Component, int)
, Container.add(Component, java.lang.Object)
, LayoutManager
, LayoutManager2
public int getScrollbarDisplayPolicy()
public Dimension getViewportSize()
public int getHScrollbarHeight()
public int getVScrollbarWidth()
public Adjustable getVAdjustable()
ScrollPaneAdjustable
object which represents the state of the vertical scrollbar. The declared return type of this method is Adjustable
to maintain backward compatibility.
ScrollPaneAdjustable
public Adjustable getHAdjustable()
ScrollPaneAdjustable
object which represents the state of the horizontal scrollbar. The declared return type of this method is Adjustable
to maintain backward compatibility.
ScrollPaneAdjustable
public void setScrollPosition(int x, int y)
x
- the x position to scroll to
y
- the y position to scroll to
NullPointerException
- if the scrollpane does not contain a child
public void setScrollPosition(Point p)
p
- the Point representing the position to scroll to
public Point getScrollPosition()
NullPointerException
- if the scrollpane does not contain a child
public final void setLayout(LayoutManager mgr)
setLayout
in class Container
mgr
- the specified layout manager
Container.doLayout()
, Container.getLayout()
public void doLayout()
doLayout
in class Container
Component.validate()
@Deprecated public void layout()
doLayout()
.
layout
in class Container
public void printComponents(Graphics g)
printComponents
in class Container
g
- the specified Graphics window
Component.print(java.awt.Graphics)
, Component.printAll(java.awt.Graphics)
public void addNotify()
addNotify
in class Container
Component.isDisplayable()
, Container.removeNotify()
public String paramString()
ScrollPane
. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null
.
paramString
in class Container
protected void processMouseWheelEvent(MouseWheelEvent e)
ScrollPane
by scrolling an appropriate amount.
Note that if the event parameter is null
the behavior is unspecified and may result in an exception.
processMouseWheelEvent
in class Component
e
- the mouse wheel event
MouseWheelEvent
, MouseWheelListener
, Component.addMouseWheelListener(java.awt.event.MouseWheelListener)
, Component.enableEvents(long)
protected boolean eventTypeEnabled(int type)
public void setWheelScrollingEnabled(boolean handleWheel)
handleWheel
- true
if scrolling should be done automatically for a MouseWheelEvent, false
otherwise.
isWheelScrollingEnabled()
, MouseWheelEvent
, MouseWheelListener
public boolean isWheelScrollingEnabled()
setWheelScrollingEnabled(boolean)
public AccessibleContext getAccessibleContext()
getAccessibleContext
in interface Accessible
getAccessibleContext
in class Component
Copyright © 2004, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4