org.gnome.gtk
Class Button
java.lang.Object
org.freedesktop.bindings.Proxy
A Widget that creates a signal when clicked on. Button can hold any just
about any other Widget as its child (TODO which means what? What
limitations?). The most commonly used child is a Label, and there are
convenience methods to help you just create a button with a given label
automatically.
static interface | Button.CLICKED - Event generated when a user presses and releases a button, causing it
to activate.
|
Button() - Create an "empty" button to use as a Container.
|
Button(String text) - Create a button with a Label as its child.
|
Button
public Button()
Create an "empty" button to use as a Container. You'll need to
add()
the Widget which will
be the Button's child.
Button
public Button(String text)
Create a button with a Label as its child. Simply specify the text you
want for the Label and a Button will be created accordingly. This is
quite a common case - in fact, we're generally more used to thinking of
Buttons as being Labels that you can press than as arbitrary Widget
Containers.
text
- the text you wish on the Label that will be created in the
Button.
connect
public void connect(Button.CLICKED handler)
Hook up a handler to receive "clicked" events on this Button. A typical
example of how this is used is as follows:
Button b;
b.connect(new Button.CLICKED() {
public void onClicked(Button source) {
// do something!
}
}
You can of course create a subclass of Button.CLICKED and then use
instances of it if you have highly complicated algorithms to implement.
If you implement Button.CLICKED in the class you're currently working
on, then you use a technique called "self-delegation" which can
sometimes work well;
b.connect(this);
getAlignmentX
public float getAlignmentX()
getLabel
public String getLabel()
Get the text showing on the Button.
- the text of the Label, or
null
if the no-arg
constructor was used and you've just got an arbitrary
Widget-containing-Button, not the more usual Button-with-Label.
getRelief
public ReliefStyle getRelief()
Get the relief style in use around this Button.
setLabel
public void setLabel(String text)
Set the text showing in the Button. (This assumes you've got a Label in
the Button in the first place, ie, you created this with
Button(String)
).
setRelief
public void setRelief(ReliefStyle style)
Set the "relief" style used to determine how the edges of this Button
will be decorated. The default is
NORMAL
which results in a Button just as you would expect, screaming out to be
pressed! There are two other variations, see
ReliefStyle
for
details.
|  java-gnome |