org.gnu.gtk
Class Button

java.lang.Object
  extended by org.gnu.glib.Struct
      extended by org.gnu.glib.GObject
          extended by org.gnu.gtk.GtkObject
              extended by org.gnu.gtk.Widget
                  extended by org.gnu.gtk.Container
                      extended by org.gnu.gtk.Bin
                          extended by org.gnu.gtk.Button
Direct Known Subclasses:
ColorButton, FontButton, OptionMenu, ToggleButton

public class Button
extends Bin

A widget that creates a signal when clicked on. This is generally used to attach a function to that is called when the button is pressed.

The gtk.Button widget can hold any valid child widget. That is it can hold most any other standard gtk.Widget. The most commonly used child is the gtk.Label.


Constructor Summary
Button()
          Creates a new Button widget
Button(GtkStockItem stockItem)
          Constructs a button using a stock item.
Button(org.gnu.glib.Handle handle)
          Construct a button using a handle to a native resource.
Button(java.lang.String stockItem)
          Constructs a button using a String that represents a stock item.
Button(java.lang.String label, boolean hasMnemonic)
          Creates a button widget with a gtk.Label child containing the given text.
 
Method Summary
 void addListener(ButtonListener listener)
          Register an object to handle button events.
 void click()
          Sends a clicked signal to the button.
 void enter()
          Sends an enter signal to the button.
static Button getButton(org.gnu.glib.Handle handle)
          Construct a button using a handle to a native resource.
 java.lang.Class getEventListenerClass(java.lang.String signal)
           
 EventType getEventType(java.lang.String signal)
           
 boolean getFocusOnClick()
           
 Widget getImage()
           
 java.lang.String getLabel()
          Returns the label which is being used on the button.
 ReliefStyle getRelief()
          Returns the current relief style of the button
static Type getType()
          Retrieve the runtime type used by the GLib library.
 boolean getUseStock()
          Returns true if this button is using stock items
 boolean getUseUnderline()
          Returns whether an embedded underline in the button label indicates a mnemonic.
 double getXAlignment()
           
 double getYAlignment()
           
 void leave()
          Sends a leave signal to the button.
 void press()
          Sends a pressed signal to the button.
 void release()
          Sends a released signal to the button.
 void removeListener(ButtonListener listener)
          Removes a listener
 void setAlignment(double xalign, double yalign)
           
 void setFocusOnClick(boolean focusOnClick)
           
 void setImage(Widget image)
           
 void setLabel(java.lang.String newLabel)
          Sets the text of the label of the button to newLabel.
 void setRelief(ReliefStyle newRelief)
          Sets the relief style of the edges of the Button widget.
 void setUseStock(boolean useStock)
          Setting this will true will make the widget try to interpret the label as a stock item.
 void setUseUnderline(boolean useUnderLine)
          If true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.
 
Methods inherited from class org.gnu.gtk.Bin
getChild
 
Methods inherited from class org.gnu.gtk.Container
add, addListener, getBooleanChildProperty, getBorderWidth, getChildProperty, getChildren, getIntChildProperty, getResizeMode, remove, removeListener, resizeChildren, setBooleanChildProperty, setBorderWidth, setChildProperty, setIntChildProperty, setResizeMode
 
Methods inherited from class org.gnu.gtk.Widget
activate, addAccelerator, addEvents, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, addListener, canActivateAccel, createContext, createLayout, draw, drawArea, drawArea, finish, getAccessible, getAllocation, getCanFocus, getColormap, getContext, getData, getDisplay, getDragData, getExtensionEvents, getModifierStyle, getName, getParent, getParentWindow, getPointer, getRootWindow, getScreen, getSensitive, getStyle, getToplevel, getWidget, getWindow, grabDefault, grabFocus, hasFocus, hasScreen, hide, hideAll, highlight, highlight, intersect, isAncestor, makeWidget, modifyStyle, popColormap, pushColormap, realize, removeAccelerator, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, removeListener, reparent, setBackgroundColor, setBaseColor, setCanFocus, setColormap, setDoubleBuffered, setDragDestination, setDragIcon, setDragIconPixbuf, setDragIconStock, setDragSource, setEvents, setExtensionEvents, setFont, setForegroundColor, setMinimumSize, setName, setNoDragDestination, setNoDragSource, setSensitive, setTextColor, shapeCombineMask, show, showAll, unHighlight, unHighlight
 
Methods inherited from class org.gnu.gtk.GtkObject
destroy, sink
 
Methods inherited from class org.gnu.glib.GObject
addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addEventHandler, addListener, collect, freezeNotify, getBooleanProperty, getData, getDoubleProperty, getFloatProperty, getGObjectFromHandle, getIntProperty, getJavaObjectProperty, getLongProperty, getPixbufProperty, getProperty, getStringProperty, hasProperty, notify, removeEventHandler, removeListener, setBooleanProperty, setData, setDoubleProperty, setFloatProperty, setIntProperty, setJavaObjectProperty, setLongProperty, setPixbufProperty, setProperty, setStringProperty, thawNotify
 
Methods inherited from class org.gnu.glib.Struct
equals, getHandle, getNullHandle, hashCode
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Button

public Button()
Creates a new Button widget


Button

public Button(java.lang.String label,
              boolean hasMnemonic)
Creates a button widget with a gtk.Label child containing the given text.

If hasMnemonic is true, the label will be interpreted as containing Mnemonic characters (keyboard accelerators). If characters in label are proceeded by an underscore character, they will be underlined. The first underlined character will be taken as the mnemonic - pressing Alt and that character will activate the button.

Parameters:
label - Text to appear on the button
hasMnemonic - See above description

Button

public Button(GtkStockItem stockItem)
Constructs a button using a stock item. Stock items are standard icons and text strings. The use of these is highly encouraged as they allow gtk themes to have greater control over applications and so give a more consistent interface to the user.
Example: Button myButton = new Button( new StockItem( StockItem.NO ); )

Parameters:
stockItem - A gtk stock item
See Also:
GtkStockItem

Button

public Button(java.lang.String stockItem)
Constructs a button using a String that represents a stock item. Stock items are standard icons and text strings. The use of these is highly encouraged as they allow gtk themes to have greater control over applications and so give a more consistent interface to the user.
Example: Button myButton = new Button( StockItem.NO; )

Parameters:
stockItem - A String representing a stock item
See Also:
GtkStockItem

Button

public Button(org.gnu.glib.Handle handle)
Construct a button using a handle to a native resource.

Method Detail

getButton

public static Button getButton(org.gnu.glib.Handle handle)
Construct a button using a handle to a native resource.


press

public void press()
Sends a pressed signal to the button. If handlers have been set up for this event then they will be called


release

public void release()
Sends a released signal to the button. If handlers have been set up for this event, they will be called.


click

public void click()
Sends a clicked signal to the button. If handlers have been set up for this event, they will be called


enter

public void enter()
Sends an enter signal to the button. If handlers have been set up for this event, they will be called.


leave

public void leave()
Sends a leave signal to the button. If handlers have been set up for this event, they will be called.


setRelief

public void setRelief(ReliefStyle newRelief)
Sets the relief style of the edges of the Button widget.


getRelief

public ReliefStyle getRelief()
Returns the current relief style of the button


setLabel

public void setLabel(java.lang.String newLabel)
Sets the text of the label of the button to newLabel. If setUseStock has been called or this object was created using stock buttons, then newLabel should be the name of the stock item to be used.


getLabel

public java.lang.String getLabel()
Returns the label which is being used on the button.


setUseUnderline

public void setUseUnderline(boolean useUnderLine)
If true, an underline in the text of the button label indicates the next character should be used for the mnemonic accelerator key.


getUseUnderline

public boolean getUseUnderline()
Returns whether an embedded underline in the button label indicates a mnemonic.


setUseStock

public void setUseStock(boolean useStock)
Setting this will true will make the widget try to interpret the label as a stock item. If the stock id is unknown, it will be treated as a normal label.

Stock items are standard icons and strings. These are included in Gtk themes, so that the appearance of all applications follows their theme. The use of stock items is highly recommended.

Parameters:
useStock - true if this button should use stock items

getUseStock

public boolean getUseStock()
Returns true if this button is using stock items


setFocusOnClick

public void setFocusOnClick(boolean focusOnClick)

getFocusOnClick

public boolean getFocusOnClick()

setAlignment

public void setAlignment(double xalign,
                         double yalign)

getXAlignment

public double getXAlignment()

getYAlignment

public double getYAlignment()

setImage

public void setImage(Widget image)

getImage

public Widget getImage()

addListener

public void addListener(ButtonListener listener)
Register an object to handle button events.

See Also:
ButtonListener

removeListener

public void removeListener(ButtonListener listener)
Removes a listener

See Also:
addListener(ButtonListener)

getEventListenerClass

public java.lang.Class getEventListenerClass(java.lang.String signal)
Overrides:
getEventListenerClass in class Container

getEventType

public EventType getEventType(java.lang.String signal)
Overrides:
getEventType in class Container

getType

public static Type getType()
Retrieve the runtime type used by the GLib library.