ClickAction
public abstract class Widget extends java.lang.Object implements ClickAction
Constructor | Description |
---|---|
Widget() |
Modifier and Type | Method | Description |
---|---|---|
boolean |
collidesWith(Widget w) |
|
boolean |
contains(int x,
int y) |
contains() true/false if x,y is inside of the bounds of this widget.
|
java.awt.Color |
getBackgroundColor() |
gets the background color
|
java.awt.Rectangle |
getBounds() |
getBounds() return a rectangle containing the bounds around this shape
|
java.awt.Color |
getForegroundColor() |
|
Window |
getWindow() |
|
int |
getX() |
Returns the x coordinate of the widget in the coordinate system of the
graphics panel.
|
int |
getY() |
Returns the y coordinate of the widget in the coordinate system of the
graphics panel.
|
void |
onClick(Command scl) |
onClick - third version of this method, this one uses a listener object
of type Command.
|
void |
onClick(java.lang.Object object) |
onClick - sets up the handler for what to do when this button is clicked.
|
void |
onClick(java.lang.Object object,
java.lang.String methodName) |
onClick - another version of callOnClick, this one specifies the method
to call in the parameter.
|
abstract void |
remove() |
|
void |
repaint() |
|
void |
setBackgroundColor(java.awt.Color color) |
Sets the background color
|
void |
setForegroundColor(java.awt.Color color) |
Sets the foreground color
|
void |
setX(int x) |
sets the Widget's location to be at its original y and the new x.
|
void |
setY(int y) |
sets the Widget's location to be at its original x and the new y.
|
public boolean contains(int x, int y)
x
- the x coordinate of the pointy
- the y coordinate of the pointpublic boolean collidesWith(Widget w)
public java.awt.Rectangle getBounds()
public int getX()
public int getY()
public void setX(int x)
x
- the x coordinate of the new locationpublic void setY(int y)
y
- the y coordinate of the new locationpublic java.awt.Color getForegroundColor()
public void setForegroundColor(java.awt.Color color)
color
- Color for the foregroundpublic java.awt.Color getBackgroundColor()
public void setBackgroundColor(java.awt.Color color)
color
- Color for the backgroundpublic void onClick(java.lang.Object object)
ClickAction
onClick
in interface ClickAction
object
- receives the call when clicked, must not be nullpublic void onClick(java.lang.Object object, java.lang.String methodName)
ClickAction
onClick
in interface ClickAction
object
- 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)
ClickAction
onClick
in interface ClickAction
scl
- command object, can't be nullpublic Window getWindow()
public abstract void remove()
public void repaint()