Class 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

public class Button extends ButtonBase
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);
  }
}

  • Constructor Details

    • Button

      public Button()
      Creates a button with no caption.
    • Button

      public Button(SafeHtml html)
      Creates a button with the given HTML caption.
      Parameters:
      html - the HTML caption
    • Button

      public Button(String html)
      Creates a button with the given HTML caption.
      Parameters:
      html - the HTML caption
    • Button

      @Deprecated public Button(String html, ClickListener listener)
      Deprecated.
      Creates a button with the given HTML caption and click listener.
      Parameters:
      html - the HTML caption
      listener - the click listener
    • Button

      public Button(SafeHtml html, ClickHandler handler)
      Creates a button with the given HTML caption and click listener.
      Parameters:
      html - the html caption
      handler - the click handler
    • Button

      public Button(String html, ClickHandler handler)
      Creates a button with the given HTML caption and click listener.
      Parameters:
      html - the HTML caption
      handler - the click handler
    • Button

      protected Button(Element element)
      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

      public static Button wrap(Element element)
      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 call RootPanel.detachNow(Widget).
      Parameters:
      element - the element to be wrapped
    • click

      public void click()
      Programmatic equivalent of the user clicking the button.
    • getButtonElement

      protected ButtonElement getButtonElement()
      Get the underlying button element.
      Returns:
      the ButtonElement