It can be added to top-level container like Frame or a component like Panel. The Scrollbar class extends the Component class.
Sr. no. |
Method name |
Description |
1. |
void addAdjustmentListener (AdjustmentListener l) |
It adds the given adjustment listener to receive instances of AdjustmentEvent from the scroll bar. |
2. |
void addNotify() |
It creates the peer of scroll bar. |
3. |
int getBlockIncrement() |
It gets the block increment of the scroll bar. |
4. |
int getMaximum() |
It gets the maximum value of the scroll bar. |
5. |
int getMinimum() |
It gets the minimum value of the scroll bar. |
6. |
int getOrientation() |
It returns the orientation of scroll bar. |
7. |
int getUnitIncrement() |
It fetches the unit increment of the scroll bar. |
8. |
int getValue() |
It fetches the current value of scroll bar. |
9. |
int getVisibleAmount() |
It fetches the visible amount of scroll bar. |
10. |
boolean getValueIsAdjusting() |
It returns true if the value is in process of changing where action results are being taken by the user. |
11. |
protected String paramString() |
It returns a string representing the state of Scroll bar. |
12. |
protected void processAdjustmentEvent (AdjustmentEvent e) |
It processes the adjustment event occurring on scroll bar by dispatching them to any registered AdjustmentListener objects. |
13. |
protected void processEvent(AWTEvent e) |
It processes the events on the scroll bar. |
14. |
void removeAdjustmentListener (AdjustmentListener l) |
It removes the given adjustment listener. Thus it no longer receives the instances of AdjustmentEvent from the scroll bar. |
15. |
void setBlockIncrement(int v) |
It sets the block increment from scroll bar. |
16. |
void setMaximum (int newMaximum) |
It sets the maximum value of the scroll bar. |
17. |
void setMinimum (int newMinimum) |
It sets the minimum value of the scroll bar. |
18. |
void setOrientation (int orientation) |
It sets the orientation for the scroll bar. |
19. |
void setUnitIncrement(int v) |
It sets the unit increment for the scroll bar. |
20. |
void setValue (int newValue) |
It sets the value of scroll bar with the given argument value. |
21. |
void setValueIsAdjusting (boolean b) |
It sets the valueIsAdjusting property to scroll bar. |
22. |
void setValues (int value, int visible, int minimum, int maximum) |
It sets the values of four properties for scroll bar: value, visible amount, minimum and maximum. |
23. |
void setVisibleAmount (int newAmount) |
It sets the visible amount of the scroll bar. |
24. |
AccessibleContext getAccessibleContext() |
It gets the accessible context related to the scroll bar. |
25. |
AdjustmentListener[] getAdjustmentListeners() |
It returns an array of al lthe adjustment listeners registered on the scroll bar. |
26. |
T[] getListeners(Class listenerType) |
It returns an array if all objects that are registered as FooListeners on the scroll bar currently. |
In the following example, we are creating a scrollbar using the Scrollbar() and adding it into the Frame.
In the following example, we are creating a Scrollbar and adding it into the Frame. Here, we are using addAdjustmentListener() method of Scrollbar class which receives the instances of AdjustmentEvent and eventually we display it in the form of Label.