|
|||||||||
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.addClickListener(new ClickListener() { public void onClick(Widget sender) { 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 |
Constructor Summary | |
---|---|
ToggleButton()
Constructor for ToggleButton . |
|
ToggleButton(Image upImage)
Constructor for ToggleButton . |
|
ToggleButton(Image upImage,
ClickListener listener)
Constructor for ToggleButton . |
|
ToggleButton(Image upImage,
Image downImage)
Constructor for ToggleButton . |
|
ToggleButton(Image upImage,
Image downImage,
ClickListener listener)
Constructor for ToggleButton . |
|
ToggleButton(java.lang.String upText)
Constructor for ToggleButton . |
|
ToggleButton(java.lang.String upText,
ClickListener listener)
Constructor for ToggleButton . |
|
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 |
---|
addClickListener, addFocusListener, addKeyboardListener, getFocusImpl, isEnabled, removeClickListener, removeFocusListener, removeKeyboardListener, setElement |
Methods inherited from class com.google.gwt.user.client.ui.Widget |
---|
doAttachChildren, doDetachChildren, getParent, isAttached, onLoad, onUnload, removeFromParent |
Methods inherited from class com.google.gwt.user.client.ui.UIObject |
---|
addStyleDependentName, addStyleName, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, 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.user.client.ui.SourcesKeyboardEvents |
---|
addKeyboardListener, removeKeyboardListener |
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 buttonpublic ToggleButton(Image upImage, ClickListener listener)
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 listenerpublic ToggleButton(Image upImage, Image downImage)
ToggleButton
.
upImage
- image for the default(up) face of the buttondownImage
- image for the down face of the buttonpublic ToggleButton(Image upImage, Image downImage, ClickListener listener)
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, ClickListener listener)
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 listenerpublic 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 buttonMethod Detail |
---|
public boolean isDown()
CustomButton
isDown
in class CustomButton
true
if the button is downpublic void setDown(boolean down)
CustomButton
setDown
in class CustomButton
down
- true
to press the button, false
otherwiseprotected void onClick()
CustomButton
CustomButton.onClickStart()
should override this method to restore the normal
widget display.
onClick
in class CustomButton
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |