A scrollbar is represented by a "slider" widget.......
using Scroll bars
Scrollbar control represents a scroll bar component in order to enable user to select from range of values.The Scrollbar class embodies a scroll bar, a familiar user-interface object. A scroll bar provides a convenient means for allowing a user to select from a range of values.Common Constructors:
- Scrollbar ():
Creates a Scrollbar instance with a range of 0-100, an initial value of 0, and vertical orientation.
- Scrollbar(int style):
Constructs a new scroll bar with the specified orientation.
- Scrollbar(int style, int initialValue, int thumbSize, int min, int max)
Constructs a new scroll bar with the specified orientation, initial value, page size, and minimum and maximum values.
common methods
- getUnitIncrement(): Gets the unit increment for this scrollbar.
syntax
int getUnitIncrement()
- getValue() : Gets the current value of this scroll bar
syntax:
int getValue()
- setBlockIncrement(int v) :Sets the block increment for this scroll bar
syntax:
void setBlockIncrement(int v)
- setMaximum(int newMaximum) :Sets the maximum value of this scroll bar.
syntax
void setMaximum(int newMaximum)
- setMinimum(int newMinimum) :Sets the minimum value of this scroll bar.
syntax
void setMinimum(int newMinimum)
- setOrientation(int orientation) :Sets the orientation for this scroll bar.
syntax:
void setOrientation(int orientation)
simple program for handling scroll bars
import java.awt.*;
import java.applet.Applet;
public class ScrollbarDemo extends Applet
{
public void init()
{
Scrollbar sb = new Scrollbar
(Scrollbar.VERTICAL, 0, 8, -100, 100);
add(sb);
}
}
output:
No comments :
Post a Comment