com.extjs.gxt.ui.client.widget.button
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.extjs.gxt.ui.client.widget.Component
              extended by com.extjs.gxt.ui.client.widget.BoxComponent
                  extended by com.extjs.gxt.ui.client.widget.button.Button
All Implemented Interfaces:
Observable, IconSupport, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.IsWidget
Direct Known Subclasses:
SplitButton, ToggleButton

public class Button
extends BoxComponent
implements IconSupport

A button component.

Events:
BeforeSelect : ButtonEvent(button, event)
Fires before this button is selected.
Select : ButtonEvent(button, event)
Fires when this button is selected.
MenuShow : ButtonEvent(button, item)
If this button has a menu, this event fires when it is shown.
MenuHide : ButtonEvent(button, item)
If this button has a menu, this event fires when it is hidden.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
protected  El buttonEl
           
protected  java.lang.String buttonSelector
           
protected  com.google.gwt.user.client.ui.AbstractImagePrototype icon
           
protected  Menu menu
           
protected  Style.ButtonScale scale
           
protected  Template template
           
protected  java.lang.String text
           
 
Fields inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustSize, cacheSizes, ensureVisibilityOnSizing, height, lastSize, layer, shim, width
 
Fields inherited from class com.extjs.gxt.ui.client.widget.Component
afterRender, attachables, baseStyle, disabled, disabledStyle, disableTextSelection, dummy, focusable, hidden, mask, maskMessage, maskMessageStyleName, monitorWindowResize, rendered, resizeHandler, setElementRender, stateId, swallowEvents, toolTip, windowResizeDelay, windowResizeTask
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
Button()
          Creates a new button.
Button(java.lang.String text)
          Creates a new button with the given text.
Button(java.lang.String text, com.google.gwt.user.client.ui.AbstractImagePrototype icon)
          Creates a new button with the given text and iconStyle.
Button(java.lang.String text, com.google.gwt.user.client.ui.AbstractImagePrototype icon, SelectionListener<ButtonEvent> listener)
          Creates a new button with the given text, iconStyle and specified selection listener.
Button(java.lang.String text, SelectionListener<ButtonEvent> listener)
          Creates a new button with the given text and specified selection listener.
 
Method Summary
 void addSelectionListener(SelectionListener<ButtonEvent> listener)
          Adds a selection listener.
protected  void afterRender()
          Called after the component has been rendered and is attached for the first time.
protected  void alignIcon(com.google.gwt.user.client.Element icon)
           
protected  void autoWidth()
           
protected  ComponentEvent createComponentEvent(com.google.gwt.user.client.Event event)
           
 Style.ButtonArrowAlign getArrowAlign()
          Returns the button's arrow alignment.
protected  El getFocusEl()
           
 com.google.gwt.user.client.ui.AbstractImagePrototype getIcon()
          Returns the button's icon style.
 Style.IconAlign getIconAlign()
          Returns the button's icon alignment.
 Menu getMenu()
          Returns the button's menu (if it has one).
 java.lang.String getMenuAlign()
          Returns the button's menu alignment.
protected  java.lang.String getMenuClass()
           
 int getMinWidth()
          Returns the button's minimum width.
 boolean getMouseEvents()
          Returns true if mouse over effect is disabled.
 Style.ButtonScale getScale()
          Returns the buttons scale.
 java.lang.String getText()
          Returns the button's text.
 java.lang.String getType()
           
 void hideMenu()
          Hide this button's menu (if it has one).
protected  void notifyShow()
           
protected  void onBlur(ButtonEvent e)
           
protected  void onClick(ComponentEvent ce)
           
 void onComponentEvent(ComponentEvent ce)
          Any events a component receives will be forwarded to this method.
protected  void onDetach()
           
protected  void onDisable()
           
protected  void onEnable()
           
protected  void onFocus(ComponentEvent ce)
           
protected  void onKeyPress(ButtonEvent be)
           
protected  void onMenuHide(ComponentEvent ce)
           
protected  void onMenuShow(ComponentEvent ce)
           
protected  void onMouseDown(ComponentEvent ce)
           
protected  void onMouseOut(ComponentEvent ce)
           
protected  void onMouseOver(ComponentEvent ce)
           
protected  void onMouseUp(ComponentEvent ce)
           
protected  void onRender(com.google.gwt.user.client.Element target, int index)
          Subclasses must override and ensure setElement is called for lazy rendered components.
protected  void onResize(int width, int height)
          Called after the component is resized, this method is empty by default but can be implemented by any subclass that needs to perform custom logic after a resize occurs.
 void removeSelectionListener(SelectionListener<ButtonEvent> listener)
          Removes a previously added listener.
protected  void setAriaState(java.lang.String stateName, java.lang.String stateValue)
           
 void setArrowAlign(Style.ButtonArrowAlign arrowAlign)
          Sets the arrow alignment (defaults to RIGHT).
 void setIcon(com.google.gwt.user.client.ui.AbstractImagePrototype icon)
          Sets the button's icon style.
 void setIconAlign(Style.IconAlign iconAlign)
          Sets the icon alignment (defaults to LEFT).
 void setIconStyle(java.lang.String icon)
          Sets the icon style.
 void setMenu(Menu menu)
          Sets the button's menu.
 void setMenuAlign(java.lang.String menuAlign)
          Sets the position to align the menu to, see El.alignTo(com.google.gwt.user.client.Element, java.lang.String, int[]) for more details (defaults to 'tl-bl?', pre-render).
 void setMinWidth(int minWidth)
          Sets he minimum width for this button (used to give a set of buttons a common width)
 void setMouseEvents(boolean handleMouseEvents)
          False to disable visual cues on mouseover, mouseout and mousedown (defaults to true).
 void setScale(Style.ButtonScale scale)
          Sets the button scale.
 void setTabIndex(int index)
          Sets the button's tab index.
 void setText(java.lang.String text)
          Sets the button's text.
 void setType(java.lang.String type)
          Submit, reset or button (defaults to 'button').
 void showMenu()
          Show this button's menu (if it has one).
 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustPosition, adjustSize, getBounds, getHeight, getHeight, getPosition, getPositionEl, getResizeEl, getShadow, getShadowOffset, getShadowPosition, getSize, getWidth, getWidth, hideShadow, hideShim, hideUnders, isAutoHeight, isAutoWidth, isDeferHeight, isShim, onHide, onPosition, onShow, onUnload, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShadowOffset, setShadowPosition, setShim, setSize, setSize, setWidth, setWidth, sync, syncSize
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addAttachable, addListener, addPlugin, addStyleName, addStyleOnOver, addWidgetListener, applyState, assertAfterRender, assertPreRender, beforeRender, blur, clearState, createObservable, createStyles, disable, disableContextMenu, disableEvents, disableTextSelection, doAttachChildren, doDetachChildren, el, enable, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, frame, getAriaSupport, getBaseStyle, getBorders, getContextMenu, getData, getElement, getFocusSupport, getHideMode, getId, getItemId, getListeners, getModel, getObservable, getPlugins, getState, getStateId, getTabIndex, getTitle, getToolTip, getWindowResizeDelay, hasListeners, hasListeners, hide, hideToolTip, initState, isDisabledEvents, isDisableTextSelection, isEnabled, isMasked, isMonitorWindowResize, isRendered, isStateful, isVisible, isVisible, mask, mask, mask, notifyHide, onAttach, onBrowserEvent, onDetachHelper, onEnsureDebugId, onHideContextMenu, onLoad, onRightClick, onShowContextMenu, onWindowResize, previewEvent, recalculate, removeAllListeners, removeAttachagle, removeFromParent, removeListener, removeStyleName, removeStyleOnOver, removeSwallow, removeToolTip, removeWidgetListener, render, render, repaint, saveState, setAriaRole, setAriaSupport, setBorders, setContextMenu, setData, setEl, setElement, setElement, setEnabled, setFiresEvents, setHideMode, setId, setIntStyleAttribute, setItemId, setModel, setMonitorWindowResize, setParent, setStateful, setStateId, setStyleAttribute, setStyleName, setTitle, setToolTip, setToolTip, setVisible, setWindowResizeDelay, setZIndex, show, sinkEvents, swallowEvent, swallowEvent, toString, unframe, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, setLayoutData
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, removeStyleDependentName, setElement, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

buttonEl

protected El buttonEl

buttonSelector

protected java.lang.String buttonSelector

icon

protected com.google.gwt.user.client.ui.AbstractImagePrototype icon

menu

protected Menu menu

scale

protected Style.ButtonScale scale

template

protected Template template

text

protected java.lang.String text
Constructor Detail

Button

public Button()
Creates a new button.


Button

public Button(java.lang.String text)
Creates a new button with the given text.

Parameters:
text - the button text

Button

public Button(java.lang.String text,
              com.google.gwt.user.client.ui.AbstractImagePrototype icon)
Creates a new button with the given text and iconStyle.

Parameters:
text - the button text
icon - the icon

Button

public Button(java.lang.String text,
              com.google.gwt.user.client.ui.AbstractImagePrototype icon,
              SelectionListener<ButtonEvent> listener)
Creates a new button with the given text, iconStyle and specified selection listener.

Parameters:
text - the button text
icon - the icon
listener - the selection listener

Button

public Button(java.lang.String text,
              SelectionListener<ButtonEvent> listener)
Creates a new button with the given text and specified selection listener.

Parameters:
text - the button's text
listener - the selection listener
Method Detail

addSelectionListener

public void addSelectionListener(SelectionListener<ButtonEvent> listener)
Adds a selection listener.

Parameters:
listener - the listener to add

getArrowAlign

public Style.ButtonArrowAlign getArrowAlign()
Returns the button's arrow alignment.

Returns:
the arrow alignment

getIcon

public com.google.gwt.user.client.ui.AbstractImagePrototype getIcon()
Returns the button's icon style.

Specified by:
getIcon in interface IconSupport
Returns:
the icon style

getIconAlign

public Style.IconAlign getIconAlign()
Returns the button's icon alignment.

Returns:
the icon alignment

getMenu

public Menu getMenu()
Returns the button's menu (if it has one).

Returns:
the menu

getMenuAlign

public java.lang.String getMenuAlign()
Returns the button's menu alignment.

Returns:
the menu alignment

getMinWidth

public int getMinWidth()
Returns the button's minimum width.

Returns:
the minWidth the minimum width

getMouseEvents

public boolean getMouseEvents()
Returns true if mouse over effect is disabled.

Returns:
the handleMouseEvents the handle mouse event state

getScale

public Style.ButtonScale getScale()
Returns the buttons scale.

Returns:
the scale

getText

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

Returns:
the button text

getType

public java.lang.String getType()
Returns:
the type

hideMenu

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


onComponentEvent

public void onComponentEvent(ComponentEvent ce)
Description copied from class: Component
Any events a component receives will be forwarded to this method. Subclasses should override as needed. The Component.onBrowserEvent(com.google.gwt.user.client.Event) method should not be overridden or modified.

Overrides:
onComponentEvent in class Component
Parameters:
ce - the base event

removeSelectionListener

public void removeSelectionListener(SelectionListener<ButtonEvent> listener)
Removes a previously added listener.

Parameters:
listener - the listener to be removed

setArrowAlign

public void setArrowAlign(Style.ButtonArrowAlign arrowAlign)
Sets the arrow alignment (defaults to RIGHT).

Parameters:
arrowAlign - the arrow alignment

setIcon

public void setIcon(com.google.gwt.user.client.ui.AbstractImagePrototype icon)
Sets the button's icon style. The style name should match a CSS style that specifies a background image using the following format:
 
 <code> .my-icon { background: url(images/icons/my-icon.png) no-repeat
 center left !important; } </code>
 
 

Specified by:
setIcon in interface IconSupport
Parameters:
icon - the icon

setIconAlign

public void setIconAlign(Style.IconAlign iconAlign)
Sets the icon alignment (defaults to LEFT).

Parameters:
iconAlign - the icon alignment

setIconStyle

public void setIconStyle(java.lang.String icon)
Description copied from interface: IconSupport
Sets the icon style.

Specified by:
setIconStyle in interface IconSupport
Parameters:
icon - a CSS style name

setMenu

public void setMenu(Menu menu)
Sets the button's menu.

Parameters:
menu - the menu

setMenuAlign

public void setMenuAlign(java.lang.String menuAlign)
Sets the position to align the menu to, see El.alignTo(com.google.gwt.user.client.Element, java.lang.String, int[]) for more details (defaults to 'tl-bl?', pre-render).

Parameters:
menuAlign - the menu alignment

setMinWidth

public void setMinWidth(int minWidth)
Sets he minimum width for this button (used to give a set of buttons a common width)

Parameters:
minWidth - the minimum width

setMouseEvents

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

Parameters:
handleMouseEvents - false to disable mouse over changes

setScale

public void setScale(Style.ButtonScale scale)
Sets the button scale.

Parameters:
scale - the scale to set

setTabIndex

public void setTabIndex(int index)
Sets the button's tab index.

Overrides:
setTabIndex in class Component
Parameters:
index - the tab index

setText

public void setText(java.lang.String text)
Sets the button's text.

Parameters:
text - the new text

setType

public void setType(java.lang.String type)
Submit, reset or button (defaults to 'button').

Parameters:
type - the new type

showMenu

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


afterRender

protected void afterRender()
Description copied from class: Component
Called after the component has been rendered and is attached for the first time. At this time, the component will be part of the DOM which is required when retrieving location and offsets.

Overrides:
afterRender in class BoxComponent

alignIcon

protected void alignIcon(com.google.gwt.user.client.Element icon)

autoWidth

protected void autoWidth()

createComponentEvent

protected ComponentEvent createComponentEvent(com.google.gwt.user.client.Event event)
Overrides:
createComponentEvent in class BoxComponent

getFocusEl

protected El getFocusEl()
Overrides:
getFocusEl in class Component

getMenuClass

protected java.lang.String getMenuClass()

notifyShow

protected void notifyShow()
Overrides:
notifyShow in class Component

onBlur

protected void onBlur(ButtonEvent e)

onClick

protected void onClick(ComponentEvent ce)

onDetach

protected void onDetach()
Overrides:
onDetach in class Component

onDisable

protected void onDisable()
Overrides:
onDisable in class Component

onEnable

protected void onEnable()
Overrides:
onEnable in class Component

onFocus

protected void onFocus(ComponentEvent ce)

onKeyPress

protected void onKeyPress(ButtonEvent be)

onMenuHide

protected void onMenuHide(ComponentEvent ce)

onMenuShow

protected void onMenuShow(ComponentEvent ce)

onMouseDown

protected void onMouseDown(ComponentEvent ce)

onMouseOut

protected void onMouseOut(ComponentEvent ce)

onMouseOver

protected void onMouseOver(ComponentEvent ce)

onMouseUp

protected void onMouseUp(ComponentEvent ce)

onRender

protected void onRender(com.google.gwt.user.client.Element target,
                        int index)
Description copied from class: Component
Subclasses must override and ensure setElement is called for lazy rendered components.

Overrides:
onRender in class Component
Parameters:
target - the target element
index - the insert location

onResize

protected void onResize(int width,
                        int height)
Description copied from class: BoxComponent
Called after the component is resized, this method is empty by default but can be implemented by any subclass that needs to perform custom logic after a resize occurs.

Overrides:
onResize in class BoxComponent
Parameters:
width - the width
height - the height

setAriaState

protected void setAriaState(java.lang.String stateName,
                            java.lang.String stateValue)
Overrides:
setAriaState in class Component