public class SimpleWindow
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
KEY_EVENT |
static int |
MOUSE_EVENT |
Constructor and Description |
---|
SimpleWindow(int width,
int height,
java.lang.String title)
Creates a window and makes it visible.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the window.
|
void |
close()
Closes the window.
|
static void |
delay(int ms)
Wait for a specified time.
|
int |
getEventType()
Returns the type of the last event.
|
int |
getHeight()
Returns the height of the window.
|
char |
getKey()
Returns the key that was pressed on a key event.
|
java.awt.Color |
getLineColor()
Returns the current line color.
|
int |
getLineWidth()
Returns the current line width.
|
int |
getMouseX()
Returns the mouse x coordinate at the last mouse click.
|
int |
getMouseY()
Returns the mouse y coordinate at the last mouse click.
|
int |
getWidth()
Returns the width of the window.
|
int |
getX()
Returns the pen's x coordinate.
|
int |
getY()
Returns the pen's y coordinate.
|
void |
lineTo(int x,
int y)
Moves the pen to a new position while drawing a line.
|
void |
moveTo(int x,
int y)
Moves the pen to a new position.
|
void |
open()
Opens the window.
|
void |
setLineColor(java.awt.Color col)
Sets the line color.
|
void |
setLineWidth(int width)
Sets the line width.
|
void |
waitForEvent()
Waits for event (mouse click or key press).
|
void |
waitForMouseClick()
Waits for a mouse click.
|
void |
writeText(java.lang.String txt)
Writes a string at the current position.
|
public static final int MOUSE_EVENT
public static final int KEY_EVENT
public SimpleWindow(int width, int height, java.lang.String title)
width
- the width of the windowheight
- the height of the windowtitle
- the title of the windowpublic int getWidth()
public int getHeight()
public void clear()
public void close()
public void open()
public void moveTo(int x, int y)
x
- the x coordinate of the new positiony
- the y coordinate of the new positionpublic void lineTo(int x, int y)
x
- the x coordinate of the new positiony
- the y coordinate of the new positionpublic void writeText(java.lang.String txt)
txt
- the string to writepublic int getX()
public int getY()
public void setLineWidth(int width)
width
- the new width (in pixels)public void setLineColor(java.awt.Color col)
col
- the new colorpublic int getLineWidth()
public java.awt.Color getLineColor()
public void waitForMouseClick()
public int getMouseX()
public int getMouseY()
public void waitForEvent()
public int getEventType()
public char getKey()
public static void delay(int ms)
ms
- the number of milliseconds to wait