Class PushButton

public class PushButton
extends CustomButton
A normal push button with custom styling.

CSS Style Rules

Example

public class PushButtonExample implements EntryPoint {

  public void onModuleLoad() {
    // Make a new button that does something when you click it.
    PushButton b = new PushButton("Jump", "Jump?", new ClickListener() {
      public void onClick(Widget sender) {
        Window.alert("Crash...");
        Window.alert("Uh Oh...");
      }
    });

    // In a real application, you would have to have css styles defined for
    // gwt-PushButton-up,gwt-PushButton-up-hovering,gwt-PushButton-up-disabled,
    // gwt-PushButton-down,.gwt-PushButton-down-hovering,.gwt-PushButton-down-disabled

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

Constructors

PushButton()Constructor for PushButton.
PushButton(Image)Constructor for PushButton.
PushButton(Image, ClickListener)Constructor for PushButton.
PushButton(Image, Image)Constructor for PushButton.
PushButton(Image, Image, ClickListener)Constructor for PushButton.
PushButton(String)Constructor for PushButton.
PushButton(String, ClickListener)Constructor for PushButton.
PushButton(String, String)Constructor for PushButton.
PushButton(String, String, ClickListener)Constructor for PushButton.

Methods

onClick()Called when the user finishes clicking on this button.
onClickCancel()Called when the user aborts a click in progress; for example, by dragging the mouse outside of the button before releasing the mouse button.
onClickStart()Called when the user begins to click on this button.

Constructor Detail

PushButton

public PushButton()
Constructor for PushButton.

PushButton

public PushButton(Image upImage)
Constructor for PushButton.

Parameters

upImage
image for the default(up) face of the button

PushButton

public PushButton(Image upImage, ClickListener listener)
Constructor for PushButton. The supplied image is used to construct the default face of the button.

Parameters

upImage
image for the default (up) face of the button
listener
the click listener

PushButton

public PushButton(Image upImage, Image downImage)
Constructor for PushButton.

Parameters

upImage
image for the default(up) face of the button
downImage
image for the down face of the button

PushButton

public PushButton(Image upImage, Image downImage, ClickListener listener)
Constructor for PushButton.

Parameters

upImage
image for the default(up) face of the button
downImage
image for the down face of the button
listener
clickListener

PushButton

public PushButton(String upText)
Constructor for PushButton. The supplied text is used to construct the default face of the button.

Parameters

upText
the text for the default (up) face of the button.

PushButton

public PushButton(String upText, ClickListener listener)
Constructor for PushButton. The supplied text is used to construct the default face of the button.

Parameters

upText
the text for the default (up) face of the button
listener
the click listener

PushButton

public PushButton(String upText, String downText)
Constructor for PushButton.

Parameters

upText
the text for the default (up) face of the button
downText
the text for down face of the button

PushButton

public PushButton(String upText, String downText, ClickListener listener)
Constructor for PushButton.

Parameters

upText
the text for the default (up) face of the button
downText
the text for down face of the button
listener
the click listener

Method Detail

onClick

protected void onClick()
Called when the user finishes clicking on this button. The default behavior is to fire the click event to listeners. Subclasses that override onClickStart() should override this method to restore the normal widget display.

onClickCancel

protected void onClickCancel()
Called when the user aborts a click in progress; for example, by dragging the mouse outside of the button before releasing the mouse button. Subclasses that override onClickStart() should override this method to restore the normal widget display.

onClickStart

protected void onClickStart()
Called when the user begins to click on this button. Subclasses may override this method to display the start of the click visually; such subclasses should also override onClick() and onClickCancel() to restore normal visual state. Each onClickStart will eventually be followed by either onClick or onClickCancel, depending on whether the click is completed.