## com.google.gwt.user.client.ui
Class ToggleButton

    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.CustomButton
                          com.google.gwt.user.client.ui.ToggleButton

All Implemented Interfaces:
  HasAllFocusHandlers, HasAllKeyHandlers, HasAllMouseHandlers, HasBlurHandlers, HasClickHandlers, HasFocusHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasKeyUpHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasHandlers, EventListener, Focusable, HasFocus, HasHTML, HasText, SourcesClickEvents, SourcesFocusEvents, SourcesKeyboardEvents, SourcesMouseEvents

    public class ToggleButton

extends CustomButton

A `ToggleButton` is a stylish stateful button which allows the user to toggle between `up` and `down` states.

### CSS Style Rules

- .gwt-ToggleButton-up/down/up-hovering/down-hovering/up-disabled/down-disabled {.html-face}

### Example

>     public class ToggleButtonExample implements EntryPoint {
>       public void onModuleLoad() {
>         // Make a new button that does something when you click it.
>         final ToggleButton toggleButton = new ToggleButton("Up", "Down");
>         toggleButton.addClickHandler(new ClickHandler() {
>           public void onClick(ClickEvent event) {
>             if (toggleButton.isDown()) {
>               Window.alert("I have been toggled down");
>             } else {
>               Window.alert("I have been toggled up");
>             }
>           }
>         });

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

>         // Add the ToggleButton to the root panel.
>         RootPanel.get().add(toggleButton);
>       }
>     }

Nested Class Summary

Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.CustomButton
`CustomButton.Face`

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.UIObject
`DEBUG_ID_PREFIX`

Constructor Summary
`ToggleButton()` Constructor for `ToggleButton`.
`ToggleButton(Image upImage)` Constructor for `ToggleButton`.
`ToggleButton(Image upImage, ClickHandler handler)` Constructor for `ToggleButton`.
`ToggleButton(Image upImage, ClickListener listener)` Deprecated. Use `#ToggleButton(Image, ClickHandler` instead
`ToggleButton(Image upImage, Image downImage)` Constructor for `ToggleButton`.
`ToggleButton(Image upImage, Image downImage, ClickHandler handler)` Constructor for `ToggleButton`.
`ToggleButton(Image upImage, Image downImage, ClickListener listener)` Deprecated. Use `#ToggleButton(Image, Image, ClickHandler` instead
`ToggleButton(java.lang.String upText)` Constructor for `ToggleButton`.
`ToggleButton(java.lang.String upText, ClickHandler handler)` Constructor for `ToggleButton`.
`ToggleButton(java.lang.String upText, ClickListener listener)` Deprecated. Use `#ToggleButton(String, ClickHandler` instead
`ToggleButton(java.lang.String upText, java.lang.String downText)` Constructor for `ToggleButton`.

Method Summary
`boolean` | `isDown()` Is this button down?
`protected void` | `onClick()` Called when the user finishes clicking on this button.
`void` | `setDown(boolean down)` Sets whether this button is down.

Methods inherited from class com.google.gwt.user.client.ui.CustomButton
`getDownDisabledFace, getDownFace, getDownHoveringFace, getHTML, getTabIndex, getText, getUpDisabledFace, getUpFace, getUpHoveringFace, onAttach, onBrowserEvent, onClickCancel, onClickStart, onDetach, setAccessKey, setEnabled, setFocus, setHTML, setTabIndex, setText`

Methods inherited from class com.google.gwt.user.client.ui.FocusWidget

`addBlurHandler, addClickHandler, addClickListener, addFocusHandler, addFocusListener, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, getFocusImpl, isEnabled, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener, setElement`

Methods inherited from class com.google.gwt.user.client.ui.Widget
`addDomHandler, addHandler, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getParent, isAttached, isOrWasAttached, onLoad, onUnload, removeFromParent, sinkEvents`

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, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, toString, unsinkEvents`

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`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Methods inherited from interface com.google.gwt.event.shared.HasHandlers
`fireEvent`

Constructor Detail

### ToggleButton

    public ToggleButton()

  Constructor for `ToggleButton`.

### ToggleButton

    public ToggleButton(Image upImage)

  Constructor for `ToggleButton`. The supplied image is used to construct the default face.

  Parameters:
    `upImage` - image for the default face of the button

### ToggleButton

    @Deprecated
    public ToggleButton(Image upImage,
                                   ClickListener listener)

  Deprecated. Use `#ToggleButton(Image, ClickHandler` instead

  Constructor for `ToggleButton`. 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

### ToggleButton

    public ToggleButton(Image upImage,
                        ClickHandler handler)

  Constructor for `ToggleButton`. The supplied image is used to construct the default face of the button.

  Parameters:
    `upImage` - image for the default (up) face of the button
    `handler` - the click handler

### ToggleButton

    public ToggleButton(Image upImage,
                        Image downImage)

  Constructor for `ToggleButton`.

  Parameters:
    `upImage` - image for the default(up) face of the button
    `downImage` - image for the down face of the button

### ToggleButton

    @Deprecated
    public ToggleButton(Image upImage,
                                   Image downImage,
                                   ClickListener listener)

  Deprecated. Use `#ToggleButton(Image, Image, ClickHandler` instead

  Constructor for `ToggleButton`.

  Parameters:
    `upImage` - image for the default(up) face of the button
    `downImage` - image for the down face of the button
    `listener` - clickListener

### ToggleButton

    public ToggleButton(Image upImage,
                        Image downImage,
                        ClickHandler handler)

  Constructor for `ToggleButton`.

  Parameters:
    `upImage` - image for the default(up) face of the button
    `downImage` - image for the down face of the button
    `handler` - the click handler

### ToggleButton

    public ToggleButton(java.lang.String upText)

  Constructor for `ToggleButton`. 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.

### ToggleButton

    @Deprecated
    public ToggleButton(java.lang.String upText,
                                   ClickListener listener)

  Deprecated. Use `#ToggleButton(String, ClickHandler` instead

  Constructor for `ToggleButton`. 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

### ToggleButton

    public ToggleButton(java.lang.String upText,
                        ClickHandler handler)

  Constructor for `ToggleButton`. 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
    `handler` - the click handler

### ToggleButton

    public ToggleButton(java.lang.String upText,
                        java.lang.String downText)

  Constructor for `ToggleButton`.

  Parameters:
    `upText` - the text for the default (up) face of the button
    `downText` - the text for down face of the button

Method Detail

### isDown

    public boolean isDown()

  Description copied from class: `CustomButton`
  Is this button down?

  Overrides:
    `isDown` in class `CustomButton`
  Returns:
    `true` if the button is down

### setDown

    public void setDown(boolean down)

  Description copied from class: `CustomButton`
  Sets whether this button is down.

  Overrides:
    `setDown` in class `CustomButton`
  Parameters:
    `down` - `true` to press the button, `false` otherwise

### onClick

    protected void onClick()

  Description copied from class: `CustomButton`
  Called when the user finishes clicking on this button. The default behavior is to fire the click event to listeners. Subclasses that override `CustomButton.onClickStart()` should override this method to restore the normal widget display.

  Overrides:
    `onClick` in class `CustomButton`