A
Scrollbar
is the interface to Java's AWT Scrollbar Component.
Yoix programs normally interact with a
Scrollbar
using event handlers and by reading or writing the following fields:
| background |
The
Color
that is used to paint the background of the scrollbar.
Reading returns a snapshot of the current color.
Writing immediately changes the background to the new color.
Storing
NULL
in
background
is special and means use the background of the nearest component
that contains the scrollbar and was assigned a background color other than
NULL;
if no component qualifies the scrollbar uses
VM.screen.background.
| | blockincrement |
A positive
int
that is the amount the scrollbar's value increases or decreases
when either of the scrollbar's block increment areas are activated.
Reading returns the current blockincrement.
Writing immediately sets the blockincrement to the new value.
| | compressevents |
An
Object
that must be a
String
or an
Array
of strings that names the events that are automatically ignored
by the Yoix interpreter when there is another event just like it
(i.e., same type and targeted at the same component) in the
event queue.
| | cursor |
An
Object
that should be an
int,
Image,
or
String
that selects the cursor shown when the pointer is over the scrollbar.
A
cursor
that is an
int
should be one of the cursors defined in the
yoix.awt.Cursor
dictionary.
A
cursor
that is an
Image
can describe the cursor using its
size
and
hotspot
fields and often draws it using its
paint
function.
A
cursor
that is a
String
should be the name of a cursor that is already defined in
yoix.awt.Cursor
or the name a local a file or URL that contains a GIF or JPEG image
that will be used as the cursor.
Reading returns the current cursor.
Writing immediately changes the scrollbar's cursor to the new value.
Storing
STANDARD_CURSOR
(the default) or
NULL
in
cursor
is special and means use the cursor assigned to the nearest component
that contains the scrollbar and was assigned a cursor other than
STANDARD_CURSOR;
if no component qualifies the scrollbar uses
DEFAULT_CURSOR.
| | enabled |
An
int
that is
1
when the scrollbar can respond to user input, and
0
otherwise.
Reading returns the current state.
Writing immediately sets the scrollbar's state to the new value.
| | focusable |
An
int
that is non-zero (the default)
when the scrollbar can accept the keyboard focus and zero
when it can not.
Reading returns the scrollbar's current focusable state.
Writing immediately changes the scrollbar's focusable state to the new value,
which means the focus is automatically transferred if the new value is zero
and the scrollbar is the current focus owner.
| | focusowner |
A read-only
int
that is non-zero when the scrollbar has the focus.
| | location |
A
Point
that determines the location of the scrollbar
in a coordinate system that has its origin at the upper left corner
of the container closest to the scrollbar (in the component hierarchy)
that actually contains it, positive x to the right, positive y down,
and a resolution of 72 dots per inch.
Reading returns a snapshot of the current location.
Writing is allowed, but layout managers usually get the final say, so setting
location
should be viewed as a request that may not be honored.
| | maximum |
An
int
that is the largest value represented by the scrollbar.
Reading returns the current maximum.
Writing immediately sets the scrollbar's maximum to the new value.
| | minimum |
An
int
that is the smallest value represented by the scrollbar.
Reading returns the current minimum.
Writing immediately sets the scrollbar's minimum to the new value.
| | orientation |
An
int
that determines the direction that the scrollbar's slider can move.
The value should be
HORIZONTAL
or
VERTICAL,
which are defined in
yoix.awt.
Reading returns the current orientation.
Writing immediately sets the scrollbar's orientation to the new value.
| | requestfocus |
An
int
that can be used to request or transfer the keyboard focus.
Storing a non-zero value in
requestfocus
tries to get the focus.
Storing
0
tries to transfer the focus.
Reading
requestfocus
does not currently return any useful information.
| | root |
An
Object
that is automatically updated by the interpreter's layout machinery
so it is always the top-level object that contains the scrollbar.
For example, put a scrollbar in a panel and
root
will be set to that panel;
add the panel to a frame and the scrollbar's
root
field will be set to that frame.
A scrollbar's event handlers can use
root
when they need to interact with the other components in the container.
| | setValues(int value, int extent, int minimum, int maximum) |
A
Builtin
that accepts 4
int
arguments specifying the
value, extent, minimum, and maximum values for the scrollbar.
setValues
provides an easy way to set all four values at once without generating
multiple state change events and without having to worry too much about
adjustments that Java sometimes quietly makes to guarantee a consistent
set of values.
| | showing |
A read-only
int
that is non-zero when the scrollbar is showing on the screen.
| | size |
A
Dimension
that determines the size of the scrollbar
in units of 72 dots per inch.
Reading returns a snapshot of the current size.
Writing is allowed, but layout managers usually get the final say, so setting
size
should be viewed as a request that may not be honored.
| | tag |
A
String
used to identify the scrollbar that is either supplied when
the scrollbar is declared, or automatically generated otherwise.
Add a scrollbar to a container, like a
Frame
or
Panel,
and the interpreter's layout machinery updates the
root
field so it points at the top-level container and then adds the scrollbar, as
tag,
to the
root.components
dictionary.
| | unitincrement |
A positive
int
that is the amount the scrollbar's value increases or decreases
when either of the scrollbar's unit increment areas are activated.
Reading returns the current unitincrement.
Writing immediately sets the unitincrement to the new value.
| | value |
An
int
that is the current value of the scrollbar, as determined by the
position of the slider, in the range:
minimum <= value <= maximum - visibleamount
Reading returns the current value.
Writing immediately sets the new value and moves the slider to the
appropriate position.
| | visible |
An
int
that is
1
when the scrollbar is visible, and
0
otherwise.
Reading returns the current visibility.
Writing immediately sets the scrollbar's visibility to the new state.
| | visibleamount |
An
int
that is the range of values represented by the slider.
Reading returns the current visibleamount.
Writing immediately sets the new visibleamount and adjusts the slider's
size so it represents the new value.
|
Several permanent fields have not been documented and should not be
used in Yoix applications.
Event handlers are functions that must be added to a scrollbar when it is
declared.
The handlers that work with scrollbars are listed below;
the names should be familiar if you have done some Java programming.
| |
| Event Handlers: |
adjustmentValueChanged,
componentHidden,
componentMoved,
componentResized,
componentShown,
dragDropEnd,
dragEnter,
dragExit,
dragGestureRecognized,
dragMouseMoved,
dragOver,
drop,
dropActionChanged,
focusGained,
focusLost,
invocationRun,
keyPressed,
keyReleased,
keyTyped,
mouseClicked,
mouseDragged,
mouseEntered,
mouseExited,
mouseMoved,
mousePressed,
mouseReleased,
mouseWheelMoved
| | |
| Example: |
The program,
import yoix.*.*;
Frame f = {
Array layout = {
new Canvas {
String tag = "$_canvas";
Color background = Color.black;
}, CENTER,
new Scrollbar {
int orientation = HORIZONTAL;
int visibleamount = 5;
adjustmentValueChanged(e) {
root.components.$_canvas.background = new Color {
double red =
(value + 0.0)/(maximum - visibleamount);
};
}
}, SOUTH,
};
};
f.visible = TRUE;
uses a horizontal scrollbar to set the background color of a canvas.
| | |
| See Also: |
Button,
Canvas,
Checkbox,
Choice,
Dialog,
FileDialog,
Frame,
Label,
List,
Panel,
postEvent,
ScrollPane,
TableColumn,
TableManager,
TextArea,
TextCanvas,
TextField,
TextTerm,
Window
|
|