Package com.google.gwt.user.client.ui
Class Button
java.lang.Object
com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.FocusWidget
com.google.gwt.user.client.ui.ButtonBase
com.google.gwt.user.client.ui.Button
- All Implemented Interfaces:
HasAllDragAndDropHandlers
,HasAllFocusHandlers
,HasAllGestureHandlers
,HasAllKeyHandlers
,HasAllMouseHandlers
,HasAllTouchHandlers
,HasBlurHandlers
,HasClickHandlers
,HasDoubleClickHandlers
,HasDragEndHandlers
,HasDragEnterHandlers
,HasDragHandlers
,HasDragLeaveHandlers
,HasDragOverHandlers
,HasDragStartHandlers
,HasDropHandlers
,HasFocusHandlers
,HasGestureChangeHandlers
,HasGestureEndHandlers
,HasGestureStartHandlers
,HasKeyDownHandlers
,HasKeyPressHandlers
,HasKeyUpHandlers
,HasMouseDownHandlers
,HasMouseMoveHandlers
,HasMouseOutHandlers
,HasMouseOverHandlers
,HasMouseUpHandlers
,HasMouseWheelHandlers
,HasTouchCancelHandlers
,HasTouchEndHandlers
,HasTouchMoveHandlers
,HasTouchStartHandlers
,HasAttachHandlers
,HasHandlers
,HasSafeHtml
,EventListener
,Focusable
,HasEnabled
,HasFocus
,HasHTML
,HasText
,HasVisibility
,IsWidget
,SourcesClickEvents
,SourcesFocusEvents
,SourcesKeyboardEvents
,SourcesMouseEvents
- Direct Known Subclasses:
ResetButton
,SubmitButton
A standard push-button widget.
CSS Style Rules
- .gwt-Button
- the outer element
Example
public class ButtonExample implements EntryPoint { public void onModuleLoad() { // Make a new button that does something when you click it. Button b = new Button("Jump!", new ClickHandler() { public void onClick(ClickEvent event) { Window.alert("How high?"); } }); // Add it to the root panel. RootPanel.get().add(b); } }
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
-
Field Summary
Fields inherited from class com.google.gwt.user.client.ui.Widget
eventsToSink
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR
-
Constructor Summary
ModifierConstructorDescriptionButton()
Creates a button with no caption.protected
This constructor may be used by subclasses to explicitly use an existing element.Creates a button with the given HTML caption.Button
(SafeHtml html, ClickHandler handler) Creates a button with the given HTML caption and click listener.Creates a button with the given HTML caption.Button
(String html, ClickHandler handler) Creates a button with the given HTML caption and click listener.Button
(String html, ClickListener listener) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoid
click()
Programmatic equivalent of the user clicking the button.protected ButtonElement
Get the underlying button element.static Button
Creates a Button widget that wraps an existing <button> element.Methods inherited from class com.google.gwt.user.client.ui.ButtonBase
getHTML, getText, setHTML, setHTML, setText
Methods inherited from class com.google.gwt.user.client.ui.FocusWidget
addBlurHandler, addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addFocusHandler, addFocusListener, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, getFocusImpl, getTabIndex, isEnabled, onAttach, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener, setAccessKey, setEnabled, setFocus, setTabIndex
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, ensureHandlers, fireEvent, getHandlerCount, getHandlerManager, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, replaceElement, setLayoutData, setParent, sinkEvents, unsinkEvents
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
Constructor Details
-
Button
public Button()Creates a button with no caption. -
Button
Creates a button with the given HTML caption.- Parameters:
html
- the HTML caption
-
Button
Deprecated.UseButton(String, ClickHandler)
insteadCreates a button with the given HTML caption and click listener.- Parameters:
html
- the HTML captionlistener
- the click listener
-
Button
Creates a button with the given HTML caption and click listener.- Parameters:
html
- the HTML captionhandler
- the click handler
-
Button
This constructor may be used by subclasses to explicitly use an existing element. This element must be a <button> element.- Parameters:
element
- the element to be used
-
-
Method Details
-
wrap
Creates a Button widget that wraps an existing <button> element. This element must already be attached to the document. If the element is removed from the document, you must callWidget.removeFromParent()
.- Parameters:
element
- the element to be wrapped
-
click
public void click()Programmatic equivalent of the user clicking the button. -
getButtonElement
Get the underlying button element.- Returns:
- the
ButtonElement
-
Button(String, ClickHandler)
instead