|
java-gnome version 4.0.7 | ||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||
java.lang.Objectorg.freedesktop.bindings.Proxy
org.gnome.glib.Object
org.gnome.gtk.Object
org.gnome.gtk.Widget
org.gnome.gtk.Container
org.gnome.gtk.Bin
org.gnome.gtk.Button
public class Button
A Widget that emits a signal when clicked on. Button can hold any just
about any other Widget as its child. The most commonly used child is a
Label, and there are convenience methods to help you just create a button
with the given text automatically, notably the
Button(String) constructor.
Since Button is a Bin it strictly only has one child. Internally, however,
it may have both an icon image and some text (which is the look commonly
seen in the action buttons in Dialog boxes). You can add such an image to a
Button by calling setImage(); this works
alongside and with setLabel(). The machinery
within Button will manage creating the necessary internal structure
(HBoxes, Alignments, etc).
| Nested Class Summary | |
|---|---|
static interface |
Button.CLICKED
Event generated when a user presses and releases a button, causing it to activate. |
| Nested classes/interfaces inherited from class org.gnome.gtk.Widget |
|---|
Widget.BUTTON_PRESS_EVENT, Widget.BUTTON_RELEASE_EVENT, Widget.ENTER_NOTIFY_EVENT, Widget.EXPOSE_EVENT, Widget.FOCUS_IN_EVENT, Widget.FOCUS_OUT_EVENT, Widget.HIDE, Widget.KEY_PRESS_EVENT, Widget.KEY_RELEASE_EVENT, Widget.LEAVE_NOTIFY_EVENT, Widget.UNMAP_EVENT, Widget.VISIBILITY_NOTIFY_EVENT |
| Constructor Summary | |
|---|---|
Button()
Create an "empty" button to use as a Container. |
|
Button(Stock stock)
Create a new Button with a Label and Image from a StockItem. |
|
Button(java.lang.String text)
Create a button with a Label as its child. |
|
| Method Summary | |
|---|---|
void |
connect(Button.CLICKED handler)
Hook up a handler to receive "clicked" events on this Button. |
void |
emitClicked()
Cause a CLICKED signal to be emitted. |
float |
getAlignmentX()
Get the horizontal alignment of the child Widget within this Button. |
float |
getAlignmentY()
Get the vertical alignment of the child Widget within this Button. |
Image |
getImage()
Get the Image associated with this Button. |
java.lang.String |
getLabel()
Get the text showing on the Button. |
ReliefStyle |
getRelief()
Get the relief style in use around this Button. |
void |
setAlignment(float xalign,
float yalign)
Set the alignment of the child Widget within the Button. |
void |
setImage(Image image)
Paint an arbitrary Image over this Button. |
void |
setLabel(java.lang.String text)
Set the text showing in the Button. |
void |
setRelief(ReliefStyle style)
Set the "relief" style used to determine how the edges of this Button will be decorated. |
| Methods inherited from class org.gnome.gtk.Bin |
|---|
getChild |
| Methods inherited from class org.gnome.gtk.Container |
|---|
add, getChildren, remove, setBorderWidth |
| Methods inherited from class org.gnome.gtk.Widget |
|---|
activate, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, getAllocation, getHasFocus, getParent, getRequisition, getToplevel, getWindow, grabFocus, hide, modifyBackground, modifyText, setCanFocus, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll |
| Methods inherited from class org.freedesktop.bindings.Proxy |
|---|
toString |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Button()
add() the Widget which will
be the Button's child.
For most uses setImage() and
setLabel() will more than take care of
things; they can be used together.
public Button(Stock stock)
stock - The stock item that will determine the text and icon of the
Button.public Button(java.lang.String text)
Note that you can use setImage() on a
Button created this way.
text - the text you wish on the Label that will be created in the
Button.| Method Detail |
|---|
public void connect(Button.CLICKED handler)
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);
public void emitClicked()
CLICKED signal to be emitted.
public float getAlignmentX()
public float getAlignmentY()
public Image getImage()
setImage() method, or
null if the Button doesn't have one set.public java.lang.String getLabel()
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.public ReliefStyle getRelief()
public void setAlignment(float xalign,
float yalign)
xalign - from 0.0f representing fully left-aligned through 1.0f
representing fully right-aligned.yalign - from 0.0f for fully top-aligned through 1.0f for fully
bottom-alignedpublic void setImage(Image image)
setLabel() in which case you will get an
icon on the left and the label text on the right.
public void setLabel(java.lang.String text)
If you created an empty Button without a Label using
Button(), this will create a Label nested in an
Alignment for you. That won't work if you create an empty
Button then put a custom Widget in place with
add() instead of employing this method
and/or setImage()).
public void setRelief(ReliefStyle style)
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 |
||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||