 |
uttonRegion Class
ButtonRegions are objects
that describe a button on a ButtonBar. For each button on a ButtonBar, a
ButtonRegion object must be instantiated, then added to the ButtonBar using the
ButtonBar's addButton method.
A ButtonRegion controls where a button is located on a ButtonBar, the behavior of
the button, and the state of the button.
Below are the methods for the ButtonRegion class:
|
 |
The constructor for the ButtonRegion class.
|
ButtonRegion(String buttonID, int buttonStart, int buttonSize)
|
|
|
 |
A method to enable or disable a button.
|
|
 |
Set the "sticky" behavior of a button
|
|
 |
Set the state of a "sticky" button
|
|
 |
A method to control the animation state of an animated button.
|
|
 |
ethod
Detail
|
 |
ButtonRegion(String
buttonID, int buttonStart, int buttonSize)
This is the
constructor for a ButtonRegion. The following parameters are required:
buttonID
This is a
programmer assigned String of characters that uniquely identifies the button on
a ButtonBar. This ID will be passed to a ButtonBarObserver
whenever a button event occurs.
buttonStart
This
parameter is the starting location of a button on a ButtonBar. If the ButtonBar
has a horizontal orientation, then this value will be the coordinate of the left
edge of the button. If the ButtonBar has a vertical orientation, then this value
will be the coordinate of the top edge of the button. The coordinate corresponds
to the number of pixels of offset from the left or top edge of the ButtonBar
image.
buttonSize
This parameter
is the size of a button on a ButtonBar. If the ButtonBar has a horizontal
orientation, then this value will be the width of the button. If the ButtonBar
has a vertical orientation, then this value will be the height of the button.
The coordinate of the right or bottom edge of a button is equal to buttonStart
+ buttonSize. |
|
 |
void
enable(boolean enable)
Calling this method with a value of
true will cause the button to be enabled on the ButtonBar. The button will be
disabled on the ButtonBar if the method is called with a value of false.
Buttons
are by default enabled when created. |
|
 |
void
stickyButton(boolean activate)
void stickyButton(boolean activate,
int popupMode)
void stickyButton(boolean activate,
int popupMode, boolean toggle)
These methods are used to create and control "sticky"
buttons.
"Sticky" buttons are buttons that "stick"
when clicked. Normally, when a button is clicked, it remains in the depressed or
"down" position only until the mouse button is released. If a "sticky"
button is in an "up" position (i.e., if it is not depressed, or "down"),
and if the mouse button is clicked and released on the "sticky"
button, then the button will be placed in the "stuck" or depressed
state. Each successive click on a "sticky" button will toggle the
state between the up and down position (unless the toggle parameter is false). A "check-box" or a "radio
button" is an example of a button that implements this type of
functionality.
The activate parameter controls whether the
button is or is not a "sticky" button. If activate is true,
then the button will function as a "sticky" button. If activate
is false, then the button will function as a normal, or "momentary contact"
button.
When buttons are created, they default to being normal (not "sticky")
buttons.
The popupMode parameter found in the second and third stickyButton
methods controls the "sticky" behavior. This parameter only affects "sticky"
buttons.
There are three valid values that can be used for the popupMode
parameter:
ButtonRegion.POPUP_NEVER (0)
This
value means that once a "sticky" button is placed in the "down"
position, it can only be returned to the "up" position by clicking on
the "sticky" button again (i.e. the state -- on or off -- toggles each
time the button is clicked). This behavior is similar to a check-box button's
behavior.
ButtonRegion.POPUP_ALWAYS (1)
This
value means that once a "sticky" button is placed in the "down"
position, the next time that any button on the button bar is clicked,
the "sticky" button will "pop-up" and return to the "up"
position. This behavior is similar to a radio button's behavior.
ButtonRegion.POPUP_WHEN_ANOTHER_STUCK
(2)
This value means that once a "sticky" button is
placed in the "down" position, the next time that any "sticky"
button on the button bar is "stuck", the formerly "stuck"
button will "pop-up" and return to the "up" position. This
behavior is similar to a radio button's behavior.
The third stickyButton method supports a toggle parameter. Normally when a sticky button is clicked, its state will be toggled: if it was in the button down position, its state will change to the button up position, and vice versa. By setting toggle to false, a sticky button in the button down position will remain in the button down position until a different button is clicked (i.e., clicking on the "stuck" button will not "unstick" the button). |
|
 |
void
setStuck(boolean buttonStuck)
If a button is a
"sticky" button, then this method can be
used to set its state.
If the value of buttonStuck is true,
then the button will be placed in its "stuck" or "down"
state.
If the value of buttonStuck is false, then the button
will be placed in its "unstuck" or "up" state. |
|
 |
void disableAnimation(boolean disable)
If
a mouseOver2 image
is specified for a ButtonBar, then buttons on the ButtonBar will be animated
with a two-frame animation whenever the mouse is moved within a button's
boundaries.
This method is used to disable or enable animation for a
single button.
If disable has a value of true, then no
animation will occur for this button.
If disable has a value of
false, then animation will occur for this button.
By default, when a
button is created animation is enabled for the button (if the ButtonBar has been
configured for animation). | |