| |
|
| javax.swing.JComponent javax.swing.JScrollBar
JScrollBar | public class JScrollBar extends JComponent implements Adjustable,Accessible(Code) | | An implementation of a scrollbar. The user positions the knob in the
scrollbar to determine the contents of the viewing area. The
program typically adjusts the display so that the end of the
scrollbar represents the end of the displayable contents, or 100%
of the contents. The start of the scrollbar is the beginning of the
displayable contents, or 0%. The position of the knob within
those bounds then translates to the corresponding percentage of
the displayable contents.
Typically, as the position of the knob in the scrollbar changes
a corresponding change is made to the position of the JViewport on
the underlying view, changing the contents of the JViewport.
Warning: Swing is not thread safe. For more
information see Swing's Threading
Policy.
Warning:
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeansTM
has been added to the java.beans package.
Please see
java.beans.XMLEncoder .
See Also: JScrollPane version: 1.87 05/05/07 author: David Kloba |
Inner Class :protected class AccessibleJScrollBar extends AccessibleJComponent implements AccessibleValue | |
Constructor Summary | |
public | JScrollBar(int orientation, int value, int extent, int min, int max) Creates a scrollbar with the specified orientation,
value, extent, minimum, and maximum.
The "extent" is the size of the viewable area. | public | JScrollBar(int orientation) | public | JScrollBar() |
Method Summary | |
public void | addAdjustmentListener(AdjustmentListener l) Adds an AdjustmentListener. | protected void | fireAdjustmentValueChanged(int id, int type, int value) Notify listeners that the scrollbar's model has changed. | public AccessibleContext | getAccessibleContext() Gets the AccessibleContext associated with this JScrollBar. | public AdjustmentListener[] | getAdjustmentListeners() Returns an array of all the AdjustmentListener s added
to this JScrollBar with addAdjustmentListener(). | public int | getBlockIncrement(int direction) Returns the amount to change the scrollbar's value by,
given a block (usually "page") up/down request. | public int | getBlockIncrement() For backwards compatibility with java.awt.Scrollbar. | public int | getMaximum() The maximum value of the scrollbar is maximum - extent. | public Dimension | getMaximumSize() The scrollbar is flexible along it's scrolling axis and
rigid along the other axis. | public int | getMinimum() Returns the minimum value supported by the scrollbar
(usually zero). | public Dimension | getMinimumSize() The scrollbar is flexible along it's scrolling axis and
rigid along the other axis. | public BoundedRangeModel | getModel() Returns data model that handles the scrollbar's four
fundamental properties: minimum, maximum, value, extent. | public int | getOrientation() Returns the component's orientation (horizontal or vertical). | public ScrollBarUI | getUI() Returns the delegate that implements the look and feel for
this component. | public String | getUIClassID() Returns the name of the LookAndFeel class for this component. | public int | getUnitIncrement(int direction) Returns the amount to change the scrollbar's value by,
given a unit up/down request. | public int | getUnitIncrement() For backwards compatibility with java.awt.Scrollbar. | public int | getValue() Returns the scrollbar's value. | public boolean | getValueIsAdjusting() True if the scrollbar knob is being dragged. | public int | getVisibleAmount() Returns the scrollbar's extent, aka its "visibleAmount". | protected String | paramString() Returns a string representation of this JScrollBar. | public void | removeAdjustmentListener(AdjustmentListener l) Removes an AdjustmentEvent listener. | public void | setBlockIncrement(int blockIncrement) Sets the blockIncrement property. | public void | setEnabled(boolean x) Enables the component so that the knob position can be changed. | public void | setMaximum(int maximum) Sets the model's maximum property. | public void | setMinimum(int minimum) Sets the model's minimum property. | public void | setModel(BoundedRangeModel newModel) Sets the model that handles the scrollbar's four
fundamental properties: minimum, maximum, value, extent. | public void | setOrientation(int orientation) Set the scrollbar's orientation to either VERTICAL or
HORIZONTAL. | public void | setUI(ScrollBarUI ui) Sets the L&F object that renders this component. | public void | setUnitIncrement(int unitIncrement) Sets the unitIncrement property. | public void | setValue(int value) Sets the scrollbar's value. | public void | setValueIsAdjusting(boolean b) Sets the model's valueIsAdjusting property. | public void | setValues(int newValue, int newExtent, int newMin, int newMax) | public void | setVisibleAmount(int extent) Set the model's extent property. | public void | updateUI() Overrides JComponent.updateUI . |
JScrollBar | public JScrollBar(int orientation, int value, int extent, int min, int max)(Code) | | Creates a scrollbar with the specified orientation,
value, extent, minimum, and maximum.
The "extent" is the size of the viewable area. It is also known
as the "visible amount".
Note: Use setBlockIncrement to set the block
increment to a size slightly smaller than the view's extent.
That way, when the user jumps the knob to an adjacent position,
one or two lines of the original contents remain in view.
exception: IllegalArgumentException - if orientation is not one of VERTICAL, HORIZONTAL See Also: JScrollBar.setOrientation See Also: JScrollBar.setValue See Also: JScrollBar.setVisibleAmount See Also: JScrollBar.setMinimum See Also: JScrollBar.setMaximum |
JScrollBar | public JScrollBar(int orientation)(Code) | | Creates a scrollbar with the specified orientation
and the following initial values:
minimum = 0
maximum = 100
value = 0
extent = 10
|
JScrollBar | public JScrollBar()(Code) | | Creates a vertical scrollbar with the following initial values:
minimum = 0
maximum = 100
value = 0
extent = 10
|
addAdjustmentListener | public void addAdjustmentListener(AdjustmentListener l)(Code) | | Adds an AdjustmentListener. Adjustment listeners are notified
each time the scrollbar's model changes. Adjustment events are
provided for backwards compatibility with java.awt.Scrollbar.
Note that the AdjustmentEvents type property will always have a
placeholder value of AdjustmentEvent.TRACK because all changes
to a BoundedRangeModels value are considered equivalent. To change
the value of a BoundedRangeModel one just sets its value property,
i.e. model.setValue(123). No information about the origin of the
change, e.g. it's a block decrement, is provided. We don't try
fabricate the origin of the change here.
Parameters: l - the AdjustmentLister to add See Also: JScrollBar.removeAdjustmentListener See Also: BoundedRangeModel.addChangeListener |
getAccessibleContext | public AccessibleContext getAccessibleContext()(Code) | | Gets the AccessibleContext associated with this JScrollBar.
For JScrollBar, the AccessibleContext takes the form of an
AccessibleJScrollBar.
A new AccessibleJScrollBar instance is created if necessary.
an AccessibleJScrollBar that serves as the AccessibleContext of this JScrollBar |
getAdjustmentListeners | public AdjustmentListener[] getAdjustmentListeners()(Code) | | Returns an array of all the AdjustmentListener s added
to this JScrollBar with addAdjustmentListener().
all of the AdjustmentListener s added or an emptyarray if no listeners have been added since: 1.4 |
getBlockIncrement | public int getBlockIncrement(int direction)(Code) | | Returns the amount to change the scrollbar's value by,
given a block (usually "page") up/down request. A ScrollBarUI
implementation typically calls this method when the user clicks
above or below the scrollbar "knob" to change the value
up or down by large amount. Subclasses my override this
method to compute a value, e.g. the change required to scroll
up or down one paragraph in a text document.
The JScrollPane component creates scrollbars (by default)
that override this method and delegate to the viewports
Scrollable view, if it has one. The Scrollable interface
provides a more specialized version of this method.
Parameters: direction - is -1 or 1 for up/down respectively the value of the blockIncrement property See Also: JScrollBar.setBlockIncrement See Also: JScrollBar.setValue See Also: Scrollable.getScrollableBlockIncrement |
getMaximum | public int getMaximum()(Code) | | The maximum value of the scrollbar is maximum - extent.
the value of the model's maximum property See Also: JScrollBar.setMaximum |
getMaximumSize | public Dimension getMaximumSize()(Code) | | The scrollbar is flexible along it's scrolling axis and
rigid along the other axis.
|
getMinimum | public int getMinimum()(Code) | | Returns the minimum value supported by the scrollbar
(usually zero).
the value of the model's minimum property See Also: JScrollBar.setMinimum |
getMinimumSize | public Dimension getMinimumSize()(Code) | | The scrollbar is flexible along it's scrolling axis and
rigid along the other axis.
|
getUnitIncrement | public int getUnitIncrement(int direction)(Code) | | Returns the amount to change the scrollbar's value by,
given a unit up/down request. A ScrollBarUI implementation
typically calls this method when the user clicks on a scrollbar
up/down arrow and uses the result to update the scrollbar's
value. Subclasses my override this method to compute
a value, e.g. the change required to scroll up or down one
(variable height) line text or one row in a table.
The JScrollPane component creates scrollbars (by default)
that override this method and delegate to the viewports
Scrollable view, if it has one. The Scrollable interface
provides a more specialized version of this method.
Parameters: direction - is -1 or 1 for up/down respectively the value of the unitIncrement property See Also: JScrollBar.setUnitIncrement See Also: JScrollBar.setValue See Also: Scrollable.getScrollableUnitIncrement |
getValueIsAdjusting | public boolean getValueIsAdjusting()(Code) | | True if the scrollbar knob is being dragged.
the value of the model's valueIsAdjusting property See Also: JScrollBar.setValueIsAdjusting |
getVisibleAmount | public int getVisibleAmount()(Code) | | Returns the scrollbar's extent, aka its "visibleAmount". In many
scrollbar look and feel implementations the size of the
scrollbar "knob" or "thumb" is proportional to the extent.
the value of the model's extent property See Also: JScrollBar.setVisibleAmount |
paramString | protected String paramString()(Code) | | Returns a string representation of this JScrollBar. 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 .
a string representation of this JScrollBar. |
setBlockIncrement | public void setBlockIncrement(int blockIncrement)(Code) | | Sets the blockIncrement property.
Note, that if the argument is equal to the value of Integer.MIN_VALUE,
the most look and feels will not provide the scrolling to the right/down.
See Also: JScrollBar.getBlockIncrement() |
setEnabled | public void setEnabled(boolean x)(Code) | | Enables the component so that the knob position can be changed.
When the disabled, the knob position cannot be changed.
Parameters: x - a boolean value, where true enables the component andfalse disables it |
setUI | public void setUI(ScrollBarUI ui)(Code) | | Sets the L&F object that renders this component.
Parameters: ui - the ScrollBarUI L&F object See Also: UIDefaults.getUI since: 1.4 |
setUnitIncrement | public void setUnitIncrement(int unitIncrement)(Code) | | Sets the unitIncrement property.
Note, that if the argument is equal to the value of Integer.MIN_VALUE,
the most look and feels will not provide the scrolling to the right/down.
See Also: JScrollBar.getUnitIncrement |
setValueIsAdjusting | public void setValueIsAdjusting(boolean b)(Code) | | Sets the model's valueIsAdjusting property. Scrollbar look and
feel implementations should set this property to true when
a knob drag begins, and to false when the drag ends. The
scrollbar model will not generate ChangeEvents while
valueIsAdjusting is true.
See Also: JScrollBar.getValueIsAdjusting See Also: BoundedRangeModel.setValueIsAdjusting |
Methods inherited from javax.swing.JComponent | void _paintImmediately(int x, int y, int w, int h)(Code)(Java Doc) public void addAncestorListener(AncestorListener listener)(Code)(Java Doc) public void addNotify()(Code)(Java Doc) public synchronized void addVetoableChangeListener(VetoableChangeListener listener)(Code)(Java Doc) boolean alwaysOnTop()(Code)(Java Doc) boolean checkIfChildObscuredBySibling()(Code)(Java Doc) void clientPropertyChanged(Object key, Object oldValue, Object newValue)(Code)(Java Doc) void compWriteObjectNotify()(Code)(Java Doc) void componentInputMapChanged(ComponentInputMap inputMap)(Code)(Java Doc) final static void computeVisibleRect(Component c, Rectangle visibleRect)(Code)(Java Doc) public void computeVisibleRect(Rectangle visibleRect)(Code)(Java Doc) public boolean contains(int x, int y)(Code)(Java Doc) public JToolTip createToolTip()(Code)(Java Doc) public void disable()(Code)(Java Doc) void dndDone()(Code)(Java Doc) TransferHandler.DropLocation dropLocationForPoint(Point p)(Code)(Java Doc) public void enable()(Code)(Java Doc) public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)(Code)(Java Doc) public void firePropertyChange(String propertyName, int oldValue, int newValue)(Code)(Java Doc) public void firePropertyChange(String propertyName, char oldValue, char newValue)(Code)(Java Doc) protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws java.beans.PropertyVetoException(Code)(Java Doc) public AccessibleContext getAccessibleContext()(Code)(Java Doc) public ActionListener getActionForKeyStroke(KeyStroke aKeyStroke)(Code)(Java Doc) final public ActionMap getActionMap()(Code)(Java Doc) final ActionMap getActionMap(boolean create)(Code)(Java Doc) public float getAlignmentX()(Code)(Java Doc) public float getAlignmentY()(Code)(Java Doc) public AncestorListener[] getAncestorListeners()(Code)(Java Doc) public boolean getAutoscrolls()(Code)(Java Doc) public int getBaseline(int width, int height)(Code)(Java Doc) public BaselineResizeBehavior getBaselineResizeBehavior()(Code)(Java Doc) public Border getBorder()(Code)(Java Doc) public Rectangle getBounds(Rectangle rv)(Code)(Java Doc) final public Object getClientProperty(Object key)(Code)(Java Doc) protected Graphics getComponentGraphics(Graphics g)(Code)(Java Doc) public JPopupMenu getComponentPopupMenu()(Code)(Java Doc) public int getConditionForKeyStroke(KeyStroke aKeyStroke)(Code)(Java Doc) boolean getCreatedDoubleBuffer()(Code)(Java Doc) public int getDebugGraphicsOptions()(Code)(Java Doc) public static Locale getDefaultLocale()(Code)(Java Doc) public FontMetrics getFontMetrics(Font font)(Code)(Java Doc) public Graphics getGraphics()(Code)(Java Doc) static void getGraphicsInvoked(Component root)(Code)(Java Doc) public int getHeight()(Code)(Java Doc) public boolean getInheritsPopupMenu()(Code)(Java Doc) final public InputMap getInputMap(int condition)(Code)(Java Doc) final public InputMap getInputMap()(Code)(Java Doc) final InputMap getInputMap(int condition, boolean create)(Code)(Java Doc) public InputVerifier getInputVerifier()(Code)(Java Doc) public Insets getInsets()(Code)(Java Doc) public Insets getInsets(Insets insets)(Code)(Java Doc) public T[] getListeners(Class<T> listenerType)(Code)(Java Doc) public Point getLocation(Point rv)(Code)(Java Doc) static Set<KeyStroke> getManagingFocusBackwardTraversalKeys()(Code)(Java Doc) static Set<KeyStroke> getManagingFocusForwardTraversalKeys()(Code)(Java Doc) public Dimension getMaximumSize()(Code)(Java Doc) public Dimension getMinimumSize()(Code)(Java Doc) public Component getNextFocusableComponent()(Code)(Java Doc) public Point getPopupLocation(MouseEvent event)(Code)(Java Doc) public Dimension getPreferredSize()(Code)(Java Doc) public KeyStroke[] getRegisteredKeyStrokes()(Code)(Java Doc) public JRootPane getRootPane()(Code)(Java Doc) public Dimension getSize(Dimension rv)(Code)(Java Doc) public Point getToolTipLocation(MouseEvent event)(Code)(Java Doc) public String getToolTipText()(Code)(Java Doc) public String getToolTipText(MouseEvent event)(Code)(Java Doc) public Container getTopLevelAncestor()(Code)(Java Doc) public TransferHandler getTransferHandler()(Code)(Java Doc) public String getUIClassID()(Code)(Java Doc) public boolean getVerifyInputWhenFocusTarget()(Code)(Java Doc) public synchronized VetoableChangeListener[] getVetoableChangeListeners()(Code)(Java Doc) public Rectangle getVisibleRect()(Code)(Java Doc) public int getWidth()(Code)(Java Doc) static byte getWriteObjCounter(JComponent comp)(Code)(Java Doc) public int getX()(Code)(Java Doc) public int getY()(Code)(Java Doc) public void grabFocus()(Code)(Java Doc) public boolean isDoubleBuffered()(Code)(Java Doc) public static boolean isLightweightComponent(Component c)(Code)(Java Doc) public boolean isManagingFocus()(Code)(Java Doc) public boolean isOpaque()(Code)(Java Doc) public boolean isOptimizedDrawingEnabled()(Code)(Java Doc) boolean isPainting()(Code)(Java Doc) final public boolean isPaintingForPrint()(Code)(Java Doc) boolean isPaintingOrigin()(Code)(Java Doc) public boolean isPaintingTile()(Code)(Java Doc) public boolean isRequestFocusEnabled()(Code)(Java Doc) public boolean isValidateRoot()(Code)(Java Doc) public void paint(Graphics g)(Code)(Java Doc) protected void paintBorder(Graphics g)(Code)(Java Doc) protected void paintChildren(Graphics g)(Code)(Java Doc) protected void paintComponent(Graphics g)(Code)(Java Doc) void paintForceDoubleBuffered(Graphics g)(Code)(Java Doc) public void paintImmediately(int x, int y, int w, int h)(Code)(Java Doc) public void paintImmediately(Rectangle r)(Code)(Java Doc) void paintToOffscreen(Graphics g, int x, int y, int w, int h, int maxX, int maxY)(Code)(Java Doc) protected String paramString()(Code)(Java Doc) public void print(Graphics g)(Code)(Java Doc) public void printAll(Graphics g)(Code)(Java Doc) protected void printBorder(Graphics g)(Code)(Java Doc) protected void printChildren(Graphics g)(Code)(Java Doc) protected void printComponent(Graphics g)(Code)(Java Doc) protected void processComponentKeyEvent(KeyEvent e)(Code)(Java Doc) protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)(Code)(Java Doc) boolean processKeyBindings(KeyEvent e, boolean pressed)(Code)(Java Doc) static boolean processKeyBindingsForAllComponents(KeyEvent e, Container container, boolean pressed)(Code)(Java Doc) protected void processKeyEvent(KeyEvent e)(Code)(Java Doc) protected void processMouseEvent(MouseEvent e)(Code)(Java Doc) protected void processMouseMotionEvent(MouseEvent e)(Code)(Java Doc) final public void putClientProperty(Object key, Object value)(Code)(Java Doc) boolean rectangleIsObscured(int x, int y, int width, int height)(Code)(Java Doc) public void registerKeyboardAction(ActionListener anAction, String aCommand, KeyStroke aKeyStroke, int aCondition)(Code)(Java Doc) public void registerKeyboardAction(ActionListener anAction, KeyStroke aKeyStroke, int aCondition)(Code)(Java Doc) public void removeAncestorListener(AncestorListener listener)(Code)(Java Doc) public void removeNotify()(Code)(Java Doc) public synchronized void removeVetoableChangeListener(VetoableChangeListener listener)(Code)(Java Doc) public void repaint(long tm, int x, int y, int width, int height)(Code)(Java Doc) public void repaint(Rectangle r)(Code)(Java Doc) public boolean requestDefaultFocus()(Code)(Java Doc) public void requestFocus()(Code)(Java Doc) public boolean requestFocus(boolean temporary)(Code)(Java Doc) public boolean requestFocusInWindow()(Code)(Java Doc) protected boolean requestFocusInWindow(boolean temporary)(Code)(Java Doc) public void resetKeyboardActions()(Code)(Java Doc) public void reshape(int x, int y, int w, int h)(Code)(Java Doc) public void revalidate()(Code)(Java Doc) static Graphics safelyGetGraphics(Component c)(Code)(Java Doc) static Graphics safelyGetGraphics(Component c, Component root)(Code)(Java Doc) public void scrollRectToVisible(Rectangle aRect)(Code)(Java Doc) final public void setActionMap(ActionMap am)(Code)(Java Doc) public void setAlignmentX(float alignmentX)(Code)(Java Doc) public void setAlignmentY(float alignmentY)(Code)(Java Doc) public void setAutoscrolls(boolean autoscrolls)(Code)(Java Doc) public void setBackground(Color bg)(Code)(Java Doc) public void setBorder(Border border)(Code)(Java Doc) public void setComponentPopupMenu(JPopupMenu popup)(Code)(Java Doc) void setCreatedDoubleBuffer(boolean newValue)(Code)(Java Doc) public void setDebugGraphicsOptions(int debugOptions)(Code)(Java Doc) public static void setDefaultLocale(Locale l)(Code)(Java Doc) public void setDoubleBuffered(boolean aFlag)(Code)(Java Doc) Object setDropLocation(TransferHandler.DropLocation location, Object state, boolean forDrop)(Code)(Java Doc) public void setEnabled(boolean enabled)(Code)(Java Doc) public void setFocusTraversalKeys(int id, Set<? extends AWTKeyStroke> keystrokes)(Code)(Java Doc) public void setFont(Font font)(Code)(Java Doc) public void setForeground(Color fg)(Code)(Java Doc) public void setInheritsPopupMenu(boolean value)(Code)(Java Doc) final public void setInputMap(int condition, InputMap map)(Code)(Java Doc) public void setInputVerifier(InputVerifier inputVerifier)(Code)(Java Doc) public void setMaximumSize(Dimension maximumSize)(Code)(Java Doc) public void setMinimumSize(Dimension minimumSize)(Code)(Java Doc) public void setNextFocusableComponent(Component aComponent)(Code)(Java Doc) public void setOpaque(boolean isOpaque)(Code)(Java Doc) void setPaintingChild(Component paintingChild)(Code)(Java Doc) public void setPreferredSize(Dimension preferredSize)(Code)(Java Doc) public void setRequestFocusEnabled(boolean requestFocusEnabled)(Code)(Java Doc) public void setToolTipText(String text)(Code)(Java Doc) public void setTransferHandler(TransferHandler newHandler)(Code)(Java Doc) protected void setUI(ComponentUI newUI)(Code)(Java Doc) void setUIProperty(String propertyName, Object value)(Code)(Java Doc) public void setVerifyInputWhenFocusTarget(boolean verifyInputWhenFocusTarget)(Code)(Java Doc) public void setVisible(boolean aFlag)(Code)(Java Doc) static void setWriteObjCounter(JComponent comp, byte count)(Code)(Java Doc) int shouldDebugGraphics()(Code)(Java Doc) void superProcessMouseMotionEvent(MouseEvent e)(Code)(Java Doc) public void unregisterKeyboardAction(KeyStroke aKeyStroke)(Code)(Java Doc) public void update(Graphics g)(Code)(Java Doc) public void updateUI()(Code)(Java Doc)
|
|
|
|