Google Web Toolkit (Beta)
Search this site:

# Class Button

public class Button
extends ButtonBase
A standard push-button widget.

### CSS Style Rules

- .gwt-Button { }

### 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 ClickListener() {
          public void onClick(Widget sender) {
            Window.alert("How high?");
          }
        });

        // Add it to the root panel.
        RootPanel.get().add(b);
      }
    }

## Constructors

Button() | Creates a button with no caption.
Button(String) | Creates a button with the given HTML caption.
Button(String, ClickListener) | Creates a button with the given HTML caption and click listener.

## Methods

click() | Programmatic equivalent of the user clicking the button.

## Constructor Detail

### Button

public Button()
Creates a button with no caption.

### Button

public Button(String html)
Creates a button with the given HTML caption.

#### Parameters

html
  the HTML caption

### Button

public Button(String html, ClickListener listener)
Creates a button with the given HTML caption and click listener.

#### Parameters

html
  the HTML caption
listener
  the click listener

## Method Detail

### click

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