com.gwtext.client.widgets
Class Button

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.gwtext.client.widgets.Component
              extended by com.gwtext.client.widgets.Button
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, Observable
Direct Known Subclasses:
SplitButton, ToolbarButton

public class Button
extends Component

Simple Button class.


Field Summary
 
Fields inherited from class com.gwtext.client.widgets.Component
config, id
 
Constructor Summary
Button()
          Create a new Button.
Button(com.google.gwt.core.client.JavaScriptObject jsObj)
           
Button(java.lang.String text)
          Create a new Button
Button(java.lang.String text, ButtonListener listener)
          Create a new Button.
Button(java.lang.String text, ButtonListener listener, java.lang.String icon)
          Create a new Button.
Button(java.lang.String text, Menu menu)
          Create a new Button.
 
Method Summary
 void addListener(ButtonListener listener)
          Add a Button listener.
protected  com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config)
           
 void focus()
          Focus the button.
 boolean getBindToForm()
           
 com.google.gwt.user.client.Element getButtonElement()
          An Ext Button consists of a table that wraps a button element.
 java.lang.String getClickEvent()
           
protected  com.google.gwt.core.client.JavaScriptObject getConfigPrototype()
           
 boolean getHandleMouseEvents()
          False to disable visual cues on mouseover, mouseout and mousedown (defaults to true).
 java.lang.String getIcon()
           
 java.lang.String getIconCls()
           
 java.lang.String getMenuAlign()
          The position to align the menu to.
 int getMinWidth()
          The minimum width for this button.
 Panel getOwnerCt()
          The Button's owner Panel, null before rendered.
 int getTabIndex()
           
 java.lang.String getText()
           
 java.lang.String getToggleGroup()
           
 java.lang.String getTooltip()
           
 java.lang.String getTooltipType()
          The type of tooltip to use.
 java.lang.String getType()
          The button's type, corresponding to the DOM input element type attribute.
 java.lang.String getXType()
          Gets the xtype for this component as registered with ComponentMgr.
 boolean hasVisibleMenu()
          Returns true if the button has a menu and it is visible.
 void hideMenu()
          Hide this button's menu (if it has one).
 boolean isDisabled()
          Returns true if button is disabled.
 boolean isEnableToggle()
           
 boolean isPressed()
          True if the Button is pressed.
 boolean isRepeat()
           
 void setClickEvent(java.lang.String clickEvent)
          The type of event to map to the button's event handler (defaults to 'click')
 void setEnableToggle(boolean enableToggle)
          True to enable pressed/not pressed toggling (defaults to false).
 void setFormBind(boolean bindToForm)
          You can bind your form buttons to the valid state of the form.
 void setHandleMouseEvents(boolean handleMouseEvents)
          False to disable visual cues on mouseover, mouseout and mousedown (defaults to true).
 void setHidden(boolean hidden)
          True to start hidden or hide rendered button (defaults to false).
 void setIcon(java.lang.String icon)
          The path to an image to display in the button (the image will be set as the background-image CSS property of the button by default, so if you want a mixed icon/text button, set cls:"x-btn-text-icon")
 void setIconCls(java.lang.String iconCls)
          A css class which sets a background image to be used as the icon for this button (defaults to undefined).
 void setMenu(Menu menu)
          Assign a button menu.
 void setMenuAlign(java.lang.String anchorPosition)
          The position to align the menu to.
 void setMinWidth(int minWidth)
          The minimum width for this button.
 void setPressed(boolean pressed)
          True to start pressed (only if enableToggle = true).
 void setRepeat(boolean repeat)
          True to repeat fire the click event while the mouse is down.
 void setRepeat(ClickRepeaterConfig qconfig)
          Fire click event when mouse is down.
 void setTabIndex(int tabIndex)
          Set a DOM tabIndex for this button.
 void setTemplate(Template template)
          A Template with which to create the Button's main element.
 void setText(java.lang.String text)
          The button text.
 void setToggleGroup(java.lang.String toggleGroup)
          The group this toggle button is a member of (only 1 per group can be pressed, only applies if enableToggle = true).
 void setTooltip(QuickTipsConfig qtipConfig)
          The tooltip for the button.
 void setTooltip(java.lang.String tooltip)
          The tooltip for the button.
 void setTooltip(java.lang.String title, java.lang.String text)
          The tooltip for the button.
 void setTooltipType(boolean quickTip)
          The type of tooltip to use.
 void setType(java.lang.String type)
          The button's type, corresponding to the DOM input element type attribute.
 void showMenu()
          Show this button's menu (if it has one).
 void toggle()
          Toggle the current state.
 void toggle(boolean state)
          Toggle the button to the passed state.
 
Methods inherited from class com.gwtext.client.widgets.Component
addClass, addClassCreated, addEvent, addEvents, addListener, addListener, addListener, addPlugin, addStyleDependentName, addStyleName, afterRender, beforeDestroy, check, checkExtVer, cloneComponent, cloneComponent, cloneConfig, destroy, disable, enable, equals, error, findParentBy, findParentByType, fireEvent, focus, focus, getApplyTo, getAttribute, getAttributeAsBoolean, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAutoShow, getCls, getComponentJS, getConfig, getConfigAsString, getCtCls, getDisabledClass, getEl, getElement, getElement, getElement, getHideMode, getHideParent, getId, getItemId, getJsObj, getOffsetHeight, getOffsetWidth, getOrCreateJsObj, getOwnerContainer, getRenderTo, getStateEvents, getStateId, getTitle, getXTypes, hashCode, hide, initComponent, isCreated, isHidden, isRendered, isVisible, isXType, isXType, onDestroy, purgeListeners, removeClass, removeStyleDependentName, removeStyleName, render, render, render, render, render, render, resumeEvents, setApplyTo, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAutoEl, setAutoEl, setAutoShow, setCls, setCtCls, setDisabled, setDisabledClass, setEl, setEl, setElement, setHeight, setHideMode, setHideParent, setId, setRenderTo, setRenderToID, setStateEvents, setStateId, setStyle, setStyle, setStyleName, setStylePrimaryName, setTitle, setVisible, setWidth, show, suspendEvents, toString
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
doAttachChildren, doDetachChildren, getParent, isAttached, onAttach, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
getAbsoluteLeft, getAbsoluteTop, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, setPixelSize, setSize, setStyleName, setStyleName, setStylePrimaryName, setVisible, sinkEvents, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Button

public Button()
Create a new Button.


Button

public Button(java.lang.String text)
Create a new Button

Parameters:
text - the button label

Button

public Button(java.lang.String text,
              Menu menu)
Create a new Button.

Parameters:
text - the Button label
menu - the Button menu

Button

public Button(java.lang.String text,
              ButtonListener listener)
Create a new Button.

Parameters:
text - the button label
listener - the Button listener.
See Also:
ButtonListenerAdapter

Button

public Button(java.lang.String text,
              ButtonListener listener,
              java.lang.String icon)
Create a new Button.

Parameters:
text - the button label
listener - the Button listener
icon - the button icon
See Also:
ButtonListenerAdapter, setIcon(String)

Button

public Button(com.google.gwt.core.client.JavaScriptObject jsObj)
Method Detail

getConfigPrototype

protected com.google.gwt.core.client.JavaScriptObject getConfigPrototype()
Specified by:
getConfigPrototype in class Component

create

protected com.google.gwt.core.client.JavaScriptObject create(com.google.gwt.core.client.JavaScriptObject config)
Specified by:
create in class Component

isDisabled

public boolean isDisabled()
Returns true if button is disabled.

Overrides:
isDisabled in class Component
Returns:
true if disabled

focus

public void focus()
Focus the button.

Overrides:
focus in class Component

getButtonElement

public com.google.gwt.user.client.Element getButtonElement()
An Ext Button consists of a table that wraps a button element. This method returns the underlying Button element.
Note: This method should be called only after the Button has been Rendered.

Returns:
the Button Element

getOwnerCt

public Panel getOwnerCt()
The Button's owner Panel, null before rendered.

Returns:
the Button's owner Panel, null before rendered.

hasVisibleMenu

public boolean hasVisibleMenu()
Returns true if the button has a menu and it is visible.

Returns:
true if menu visible

hideMenu

public void hideMenu()
Hide this button's menu (if it has one).


showMenu

public void showMenu()
Show this button's menu (if it has one).


toggle

public void toggle()
Toggle the current state.


toggle

public void toggle(boolean state)
Toggle the button to the passed state.

Parameters:
state - true to toggle pressed

addListener

public void addListener(ButtonListener listener)
Add a Button listener.

Parameters:
listener - the listener

getXType

public java.lang.String getXType()
Description copied from class: Component
Gets the xtype for this component as registered with ComponentMgr. For a list of all available xtypes, see the Component javadocs.

 
 

TextField field = new TextField(); field.getXType() returns "textfield"

Overrides:
getXType in class Component
Returns:
the xtype

setClickEvent

public void setClickEvent(java.lang.String clickEvent)
                   throws java.lang.IllegalStateException
The type of event to map to the button's event handler (defaults to 'click')

Parameters:
clickEvent - the click event
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

getClickEvent

public java.lang.String getClickEvent()
Returns:
the type of event to map to the button's event handler (defaults to 'click')

setEnableToggle

public void setEnableToggle(boolean enableToggle)
True to enable pressed/not pressed toggling (defaults to false).

Parameters:
enableToggle - true to enable toggle

isEnableToggle

public boolean isEnableToggle()
Returns:
true if toggle enabled

setFormBind

public void setFormBind(boolean bindToForm)
You can bind your form buttons to the valid state of the form. Note: the Form's monitorValid config must be set to true. To bind a button(s) enabled state to the valid state set this property to true.

Parameters:
bindToForm - to to bind to form's valid state

getBindToForm

public boolean getBindToForm()
Returns:
true if bind to form is enabled

setHandleMouseEvents

public void setHandleMouseEvents(boolean handleMouseEvents)
                          throws java.lang.IllegalStateException
False to disable visual cues on mouseover, mouseout and mousedown (defaults to true).

Parameters:
handleMouseEvents - false to diable visual cues
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

getHandleMouseEvents

public boolean getHandleMouseEvents()
False to disable visual cues on mouseover, mouseout and mousedown (defaults to true).

Returns:
true if visual cues on mouseover, mouseout and mousedown are enabled

setHidden

public void setHidden(boolean hidden)
True to start hidden or hide rendered button (defaults to false).

Parameters:
hidden - true for hidden

setIcon

public void setIcon(java.lang.String icon)
The path to an image to display in the button (the image will be set as the background-image CSS property of the button by default, so if you want a mixed icon/text button, set cls:"x-btn-text-icon")

Parameters:
icon - the icon

getIcon

public java.lang.String getIcon()
Returns:
the path of the Button icon image

setIconCls

public void setIconCls(java.lang.String iconCls)
A css class which sets a background image to be used as the icon for this button (defaults to undefined).

Parameters:
iconCls - the icon CSS class

getIconCls

public java.lang.String getIconCls()
Returns:
the icon CSS class for this Button

setMenu

public void setMenu(Menu menu)
             throws java.lang.IllegalStateException
Assign a button menu.

Parameters:
menu - the button menu
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setMenuAlign

public void setMenuAlign(java.lang.String anchorPosition)
The position to align the menu to. Defaults to tl-bl?

Parameters:
anchorPosition - the element's anchor position

getMenuAlign

public java.lang.String getMenuAlign()
The position to align the menu to. Defaults to tl-bl?

Returns:
the position to align the menu to

setMinWidth

public void setMinWidth(int minWidth)
                 throws java.lang.IllegalStateException
The minimum width for this button.

Parameters:
minWidth - the min width
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

getMinWidth

public int getMinWidth()
The minimum width for this button.

Returns:
the Button min width

setPressed

public void setPressed(boolean pressed)
True to start pressed (only if enableToggle = true).

Parameters:
pressed - true for pressed

isPressed

public boolean isPressed()
True if the Button is pressed.

Returns:
true if start Button pressed (only if enableToggle = true)
See Also:
toggle(boolean)

setRepeat

public void setRepeat(boolean repeat)
True to repeat fire the click event while the mouse is down. (defaults to false).

Parameters:
repeat - true to repeat

isRepeat

public boolean isRepeat()
Returns:
true to repeat fire the click event while the mouse is down

setRepeat

public void setRepeat(ClickRepeaterConfig qconfig)
Fire click event when mouse is down.

Parameters:
qconfig - the click repeat configuration

setTabIndex

public void setTabIndex(int tabIndex)
                 throws java.lang.IllegalStateException
Set a DOM tabIndex for this button.

Parameters:
tabIndex - the tab index
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

getTabIndex

public int getTabIndex()
Returns:
the tab index, 0 if undefined

setTemplate

public void setTemplate(Template template)
A Template with which to create the Button's main element. This Template must contain numeric substitution parameter 0 if it is to display the text property. Changing the template could require code modifications if required elements (e.g. a button) aren't present. The defaut tempalte is
 

 <table border="0" cellpadding="0" cellspacing="0" class="x-btn-wrap"><tbody><tr>
   <td class="x-btn-left"><i> </i></td><td class="x-btn-center"><em unselectable="on"><button class="x-btn-text" type="{1}">{0}</button></em></td><td class="x-btn-right"><i> </i></td>
 </tr></tbody></table>
 
 

Parameters:
template - the button template

setText

public void setText(java.lang.String text)
The button text.

Parameters:
text - the buttons text

getText

public java.lang.String getText()
Returns:
the Button's text

setToggleGroup

public void setToggleGroup(java.lang.String toggleGroup)
                    throws java.lang.IllegalStateException
The group this toggle button is a member of (only 1 per group can be pressed, only applies if enableToggle = true).

Parameters:
toggleGroup - the button's toggle group
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

getToggleGroup

public java.lang.String getToggleGroup()
Returns:
the Button's toggle group

setTooltip

public void setTooltip(java.lang.String tooltip)
The tooltip for the button.

Parameters:
tooltip - the tooltip

getTooltip

public java.lang.String getTooltip()
Returns:
the Button tooltip

setTooltip

public void setTooltip(java.lang.String title,
                       java.lang.String text)
The tooltip for the button.

Parameters:
title - the tootlip title
text - the tootlip text

setTooltip

public void setTooltip(QuickTipsConfig qtipConfig)
                throws java.lang.IllegalStateException
The tooltip for the button.

Parameters:
qtipConfig - the tooltip config
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

setTooltipType

public void setTooltipType(boolean quickTip)
                    throws java.lang.IllegalStateException
The type of tooltip to use.

Parameters:
quickTip - true for quicktips, false for the "title" attribute.
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

getTooltipType

public java.lang.String getTooltipType()
The type of tooltip to use.

Returns:
the tooltip type

setType

public void setType(java.lang.String type)
             throws java.lang.IllegalStateException
The button's type, corresponding to the DOM input element type attribute. Either "submit," "reset" or "button" (default).

Parameters:
type - the button type
Throws:
java.lang.IllegalStateException - this property cannot be changed after the Component has been rendered

getType

public java.lang.String getType()
The button's type, corresponding to the DOM input element type attribute. Either "submit," "reset" or "button" (default).

Returns:
the Button type