ClickActionpublic class Button extends Widget
Window, change the title of the
button, and perform actions when the button is clicked. There are two ways to
perform an action.
1) onClick(object) - this will call a method named
"clicked" + title on "object"; where title is the title of the button. 2)
onClick(object, name) - this will call a
method named "name" on "object".| Constructor | Description |
|---|---|
Button() |
Constructor, by default has "Untitled" as title.
|
Button(java.lang.String title) |
Constructor for the button with "title".
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
disable() |
Disables this button.
|
void |
enable() |
Enables this button.
|
java.lang.String |
getTitle() |
Returns the title for the button.
|
void |
onClick(Command scl) |
Same as @see CS2114.Button.onClick(Object, String) except uses a listener
object of type Command.
|
void |
onClick(java.lang.Object object) |
Sets up the handler for what to do when this button is clicked.
|
void |
onClick(java.lang.Object object,
java.lang.String methodName) |
Specifies the method to call in the parameter.
|
void |
remove() |
|
void |
setTitle(java.lang.String title) |
Sets the title for the button.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcollidesWith, contains, getBackgroundColor, getBounds, getForegroundColor, getWindow, getX, getY, repaint, setBackgroundColor, setForegroundColor, setX, setYpublic Button()
public Button(java.lang.String title)
title - the title for the button, cannot be nullpublic void setTitle(java.lang.String title)
title - the title for the button, cannot be nullpublic java.lang.String getTitle()
public void enable()
public void disable()
public void onClick(java.lang.Object object)
onClick in interface ClickActiononClick in class Widgetobject - receives the call when clicked, must not be nullpublic void onClick(java.lang.Object object,
java.lang.String methodName)
onClick apply.
if the method doesn't exist, this will generate an exception
(NoSuchMethod).onClick in interface ClickActiononClick in class Widgetobject - receives the call upon click, can't be nullmethodName - name of method to be called, can't be nullapply.
if the method doesn't exist, this will generate an exception
(NoSuchMethod).public void onClick(Command scl)
onClick in interface ClickActiononClick in class Widgetscl - command object, can't be null