|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--java.applet.Applet | +--javax.swing.JApplet | +--acm.program.Program | +--acm.program.GraphicsProgram
This class is a standard subclass of Program whose principal window is used for drawing graphics.
Method Summary | |
void | add(GObject gobj) |
void | add(GObject gobj,
double x,
double y) |
void | add(GObject gobj,
GPoint pt) |
void | addKeyListeners() |
void | addKeyListeners(KeyListener listener) |
void | addMouseListeners() |
void | addMouseListeners(EventListener listener) |
GObject | getElement(int index) |
GObject | getElementAt(double x,
double y) |
GObject | getElementAt(GPoint pt) |
int | getElementCount() |
GCanvas | getGCanvas() |
void | init() |
Iterator | iterator() |
Iterator | iterator(int direction) |
void | remove(GObject gobj) |
void | removeAll() |
void | run() |
void | waitForClick() |
Inherited Method Summary | |
IOConsole | getConsole() |
IODialog | getDialog() |
BufferedReader | getReader()BufferedReader whose input comes from the console.
|
String | getTitle() |
PrintWriter | getWriter()PrintWriter whose output is directed to the console.
|
void | pause(double milliseconds) |
void | print(String value) |
void | println() |
void | println(String value) |
boolean | readBoolean()true or false ).
|
boolean | readBoolean(String prompt) |
boolean | readBoolean(String prompt, String trueLabel, String falseLabel) |
double | readDouble() |
double | readDouble(String prompt) |
int | readInt() |
int | readInt(String prompt) |
String | readLine() |
String | readLine(String prompt) |
void | setTitle(String title) |
Method Detail |
public void add(GObject gobj)
Usage: | add(gobj); | ||
Parameter: |
|
public final void add(GObject gobj,
double x,
double y)
Usage: | add(gobj, x, y); | ||||||
Parameters: |
|
public final void add(GObject gobj,
GPoint pt)
Usage: | add(gobj, pt); | ||||
Parameters: |
|
public void addKeyListeners()
Usage: | addKeyListeners(); |
public void addKeyListeners(KeyListener listener)
Usage: | addKeyListeners(listener); | ||
Parameter: |
|
public void addMouseListeners()
Usage: | addMouseListeners(); |
public void addMouseListeners(EventListener listener)
Usage: | addMouseListeners(listener); | ||
Parameter: |
|
public GObject getElement(int index)
Usage: | GObject gobj = getElement(index); | ||
Parameter: |
| ||
Returns: | The graphical object at the specified index |
public GObject getElementAt(double x,
double y)
Usage: | GObject gobj = program.getElementAt(x, y); | ||||
Parameters: |
| ||||
Returns: | The graphical object at the specified location, or nullif no such object exists. |
public final GObject getElementAt(GPoint pt)
Usage: | GObject gobj = program.getElementAt(pt); | ||
Parameter: |
| ||
Returns: | The graphical object at the specified location, or nullif no such object exists |
public int getElementCount()
Usage: | int n = getElementCount(); |
Returns: | The number of graphical objects in this GCanvas |
public GCanvas getGCanvas()
Usage: | GCanvas gc = getGCanvas(); |
Returns: | The GCanvas object used by the program |
public void init()
Usage: | program.init(); |
public Iterator iterator()
Applets that want to run in browsers, however, should avoid using this method, because Iterator is not supported on 1.1 browsers. For maximum portability, you should rely instead on the getElementCount and getElement methods, which provide the same functionality in a browser-compatible way.
Usage: | Iterator i = iterator(); |
Returns: | An Iterator ranging over the elements of the container from back to front |
public Iterator iterator(int direction)
for (Iterator i = iterator(direction); i.hasNext(); )
Applets that want to run in browsers, however, should avoid using this method, because Iterator is not supported on 1.1 browsers. For maximum portability, you should rely instead on the getElementCount and getElement methods, which provide the same functionality in a browser-compatible way.
Usage: | Iterator i = iterator(direction); |
Returns: | An Iterator ranging over the elements of the container in the specified direction |
public void remove(GObject gobj)
Usage: | remove(gobj); | ||
Parameter: |
|
public void removeAll()
Usage: | removeAll(); |
public void run()
public void waitForClick()
Usage: | waitForClick(); |
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |