|
|||||||||
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
public abstract class CustomButton
Custom Button is a base button class with built in support for a set number
of button faces.
Each face has its own style modifier. For example, the state for down and
hovering is assigned the CSS modifier down-hovering. So, if the
button's overall style name is gwt-PushButton then when showing the
down-hovering
face, the button's style is
gwt-PushButton-down-hovering. The overall style name can be used to
change the style of the button irrespective of the current face.
Each button face can be assigned is own image, text, or html contents. If no
content is defined for a face, then the face will use the contents of another
face. For example, if down-hovering
does not have defined
contents, it will use the contents defined by the down
face.
The supported faces are defined below:
CSS style name | Getter method | description of face | defaults to contents of face |
up | getUpFace() |
face shown when button is up | none |
down | getDownFace() |
face shown when button is down | up |
up-hovering | getUpHoveringFace() |
face shown when button is up and hovering | up |
up-disabled | getUpDisabledFace() |
face shown when button is up and disabled | up |
down-hovering | getDownHoveringFace() |
face shown when button is down and hovering | down |
down-disabled | getDownDisabledFace() |
face shown when button is down and disabled | down |
Nested Class Summary | |
---|---|
class |
CustomButton.Face
Represents a button's face. |
Constructor Summary | |
---|---|
protected |
CustomButton()
Constructor for CustomButton . |
|
CustomButton(Image upImage)
Constructor for CustomButton . |
|
CustomButton(Image upImage,
ClickListener listener)
Constructor for CustomButton . |
|
CustomButton(Image upImage,
Image downImage)
Constructor for CustomButton . |
|
CustomButton(Image upImage,
Image downImage,
ClickListener listener)
Constructor for CustomButton . |
|
CustomButton(java.lang.String upText)
Constructor for CustomButton . |
|
CustomButton(java.lang.String upText,
ClickListener listener)
Constructor for CustomButton . |
|
CustomButton(java.lang.String upText,
java.lang.String downText)
Constructor for CustomButton . |
|
CustomButton(java.lang.String upText,
java.lang.String downText,
ClickListener listener)
Constructor for CustomButton . |
Method Summary | |
---|---|
CustomButton.Face |
getDownDisabledFace()
Gets the downDisabled face of the button. |
CustomButton.Face |
getDownFace()
Gets the down face of the button. |
CustomButton.Face |
getDownHoveringFace()
Gets the downHovering face of the button. |
java.lang.String |
getHTML()
Gets the current face's html. |
int |
getTabIndex()
Gets the widget's position in the tab index. |
java.lang.String |
getText()
Gets the current face's text. |
CustomButton.Face |
getUpDisabledFace()
Gets the upDisabled face of the button. |
CustomButton.Face |
getUpFace()
Gets the up face of the button. |
CustomButton.Face |
getUpHoveringFace()
Gets the upHovering face of the button. |
protected boolean |
isDown()
Is this button down? |
protected void |
onAttach()
Overridden on attach to ensure that a button face has been chosen before the button is displayed. |
void |
onBrowserEvent(Event event)
Fired whenever a browser event is received. |
protected void |
onClick()
Called when the user finishes clicking on this button. |
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. |
protected void |
onClickStart()
Called when the user begins to click on this button. |
protected void |
onDetach()
This method is called when a widget is detached from the browser's document. |
void |
setAccessKey(char key)
Sets the widget's 'access key'. |
protected void |
setDown(boolean down)
Sets whether this button is down. |
void |
setEnabled(boolean enabled)
Sets whether this button is enabled. |
void |
setFocus(boolean focused)
Explicitly focus/unfocus this widget. |
void |
setHTML(java.lang.String html)
Sets the current face's html. |
void |
setTabIndex(int index)
Sets the widget's position in the tab index. |
void |
setText(java.lang.String text)
Sets the current face's text. |
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 CustomButton(Image upImage)
CustomButton
.
upImage
- image for the default (up) face of the buttonpublic CustomButton(Image upImage, Image downImage)
CustomButton
.
upImage
- image for the default (up) face of the buttondownImage
- image for the down face of the buttonpublic CustomButton(Image upImage, Image downImage, ClickListener listener)
CustomButton
.
upImage
- image for the default (up) face of the buttondownImage
- image for the down face of the buttonlistener
- clickListenerpublic CustomButton(Image upImage, ClickListener listener)
CustomButton
.
upImage
- image for the default (up) face of the buttonlistener
- the click listenerpublic CustomButton(java.lang.String upText)
CustomButton
.
upText
- the text for the default (up) face of the button.public CustomButton(java.lang.String upText, ClickListener listener)
CustomButton
.
upText
- the text for the default (up) face of the buttonlistener
- the click listenerpublic CustomButton(java.lang.String upText, java.lang.String downText)
CustomButton
.
upText
- the text for the default (up) face of the buttondownText
- the text for the down face of the buttonpublic CustomButton(java.lang.String upText, java.lang.String downText, ClickListener listener)
CustomButton
.
upText
- the text for the default (up) face of the buttondownText
- the text for the down face of the buttonlistener
- the click listenerprotected CustomButton()
CustomButton
.
Method Detail |
---|
public final CustomButton.Face getDownDisabledFace()
public final CustomButton.Face getDownFace()
public final CustomButton.Face getDownHoveringFace()
public java.lang.String getHTML()
getHTML
in interface HasHTML
getHTML
in class ButtonBase
public int getTabIndex()
HasFocus
getTabIndex
in interface HasFocus
getTabIndex
in class FocusWidget
public java.lang.String getText()
getText
in interface HasText
getText
in class ButtonBase
public final CustomButton.Face getUpDisabledFace()
public final CustomButton.Face getUpFace()
public final CustomButton.Face getUpHoveringFace()
public void onBrowserEvent(Event event)
EventListener
onBrowserEvent
in interface EventListener
onBrowserEvent
in class FocusWidget
event
- the event receivedpublic void setAccessKey(char key)
HasFocus
setAccessKey
in interface HasFocus
setAccessKey
in class FocusWidget
key
- the widget's access keypublic final void setEnabled(boolean enabled)
setEnabled
in class FocusWidget
enabled
- true
to enable the button, false
to disable itpublic void setFocus(boolean focused)
HasFocus
setFocus
in interface HasFocus
setFocus
in class FocusWidget
focused
- whether this widget should take focus or release itpublic void setHTML(java.lang.String html)
setHTML
in interface HasHTML
setHTML
in class ButtonBase
html
- html to setpublic void setTabIndex(int index)
HasFocus
-1
will cause this widget to
be removed from the tab order.
setTabIndex
in interface HasFocus
setTabIndex
in class FocusWidget
index
- the widget's tab indexpublic void setText(java.lang.String text)
setText
in interface HasText
setText
in class ButtonBase
text
- text to setprotected boolean isDown()
true
if the button is downprotected void onAttach()
onAttach
in class Widget
protected void onClick()
onClickStart()
should override this method to restore the normal
widget display.
protected void onClickCancel()
onClickStart()
should override this
method to restore the normal widget display.
protected void onClickStart()
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.
protected void onDetach()
Widget
Widget.onUnload()
method.
Subclasses that override this method must call
super.onDetach()
to ensure that the Widget has been detached
from the underlying Element. Failure to do so will result in application
memory leaks due to circular references between DOM Elements and JavaScript
objects.
onDetach
in class Widget
protected void setDown(boolean down)
down
- true
to press the button, false
otherwise
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |