|
GWT 2.7.0 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.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
public class ToggleButton
A ToggleButton is a stylish stateful button which allows the
user to toggle between up and down states.
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.Widget |
|---|
eventsToSink |
| Fields inherited from class com.google.gwt.user.client.ui.UIObject |
|---|
DEBUG_ID_PREFIX, MISSING_ELEMENT_ERROR, SETELEMENT_TWICE_ERROR |
| 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. |
|
ToggleButton(java.lang.String upText,
java.lang.String downText,
ClickHandler handler)
Constructor for ToggleButton. |
|
| Method Summary | |
|---|---|
HandlerRegistration |
addValueChangeHandler(ValueChangeHandler<java.lang.Boolean> handler)
Adds a ValueChangeEvent handler. |
LeafValueEditor<java.lang.Boolean> |
asEditor()
Returns the Editor encapsulated by the view object. |
java.lang.Boolean |
getValue()
Determines whether this button is currently down. |
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. |
void |
setValue(java.lang.Boolean value)
Sets whether this button is down. |
void |
setValue(java.lang.Boolean value,
boolean fireEvents)
Sets whether this button is down, firing ValueChangeEvent if
appropriate. |
| Methods inherited from class com.google.gwt.user.client.ui.CustomButton |
|---|
finishSetup, fireClickListeners, getCurrentFace, getDownDisabledFace, getDownFace, getDownHoveringFace, getHTML, getTabIndex, getText, getUpDisabledFace, getUpFace, getUpHoveringFace, isHovering, onAttach, onBrowserEvent, onClickCancel, onClickStart, onDetach, setAccessKey, setCurrentFace, setEnabled, setFocus, setHovering, setHTML, setHTML, setTabIndex, setText, toggleDown |
| 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, 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 Detail |
|---|
public ToggleButton()
ToggleButton.
public ToggleButton(Image upImage)
ToggleButton. The supplied image is used to
construct the default face.
upImage - image for the default face of the button
public ToggleButton(Image upImage,
ClickHandler handler)
ToggleButton. The supplied image is used to
construct the default face of the button.
upImage - image for the default (up) face of the buttonhandler - the click handler
@Deprecated
public ToggleButton(Image upImage,
ClickListener listener)
ToggleButton(Image, ClickHandler) instead
ToggleButton. The supplied image is used to
construct the default face of the button.
upImage - image for the default (up) face of the buttonlistener - the click listener
public ToggleButton(Image upImage,
Image downImage)
ToggleButton.
upImage - image for the default(up) face of the buttondownImage - image for the down face of the button
public ToggleButton(Image upImage,
Image downImage,
ClickHandler handler)
ToggleButton.
upImage - image for the default(up) face of the buttondownImage - image for the down face of the buttonhandler - the click handler
@Deprecated
public ToggleButton(Image upImage,
Image downImage,
ClickListener listener)
ToggleButton(Image, Image, ClickHandler) instead
ToggleButton.
upImage - image for the default(up) face of the buttondownImage - image for the down face of the buttonlistener - clickListenerpublic ToggleButton(java.lang.String upText)
ToggleButton. The supplied text is used to
construct the default face of the button.
upText - the text for the default (up) face of the button.
public ToggleButton(java.lang.String upText,
ClickHandler handler)
ToggleButton. The supplied text is used to
construct the default face of the button.
upText - the text for the default (up) face of the buttonhandler - the click handler
@Deprecated
public ToggleButton(java.lang.String upText,
ClickListener listener)
ToggleButton(String, ClickHandler) instead
ToggleButton. The supplied text is used to
construct the default face of the button.
upText - the text for the default (up) face of the buttonlistener - the click listener
public ToggleButton(java.lang.String upText,
java.lang.String downText)
ToggleButton.
upText - the text for the default (up) face of the buttondownText - the text for down face of the button
public ToggleButton(java.lang.String upText,
java.lang.String downText,
ClickHandler handler)
ToggleButton.
upText - the text for the default (up) face of the buttondownText - the text for down face of the buttonhandler - the click handler| Method Detail |
|---|
public HandlerRegistration addValueChangeHandler(ValueChangeHandler<java.lang.Boolean> handler)
HasValueChangeHandlersValueChangeEvent handler.
addValueChangeHandler in interface HasValueChangeHandlers<java.lang.Boolean>handler - the handler
public LeafValueEditor<java.lang.Boolean> asEditor()
IsEditor
asEditor in interface IsEditor<LeafValueEditor<java.lang.Boolean>>Editor of type Epublic java.lang.Boolean getValue()
getValue in interface TakesValue<java.lang.Boolean>getValue in interface HasValue<java.lang.Boolean>true if the button is pressed, false otherwise. Will
not return nullTakesValue.setValue(V)public boolean isDown()
CustomButton
isDown in class CustomButtontrue if the button is downpublic void setDown(boolean down)
ValueChangeEvent. (If you want the
event to fire, use setValue(Boolean, boolean))
setDown in class CustomButtondown - true to press the button, false
otherwisepublic void setValue(java.lang.Boolean value)
setValue in interface TakesValue<java.lang.Boolean>setValue in interface HasValue<java.lang.Boolean>value - true to press the button, false otherwise; null value implies
falseTakesValue.getValue()
public void setValue(java.lang.Boolean value,
boolean fireEvents)
ValueChangeEvent if
appropriate.
setValue in interface HasValue<java.lang.Boolean>value - true to press the button, false otherwise; null value implies
falsefireEvents - If true, and value has changed, fire a
ValueChangeEventprotected void onClick()
CustomButtonCustomButton.onClickStart() should override this method to restore the normal
widget display.
onClick in class CustomButton
|
GWT 2.7.0 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||