public class SimpleWindow
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
CLOSE_EVENT |
static int |
KEY_EVENT |
static int |
MOUSE_EVENT |
static int |
TIMEOUT_EVENT |
static int |
TIMEOUT_FOREVER |
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 |
addSprite(Sprite sprite)
Adds a sprite to the window.
|
void |
clear()
Clears the window.
|
void |
close()
Closes the window.
|
static void |
delay(int ms)
Wait for a specified time.
|
void |
drawImage(java.awt.Image image)
Draws a bitmap image at the current position.
|
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.
|
static void |
setExitOnLastClose(boolean exitOnLastClose) |
void |
setLineColor(java.awt.Color col)
Sets the line color.
|
void |
setLineWidth(int width)
Sets the line width.
|
void |
waitForEvent()
Waits forever for event (mouse click or key press).
|
void |
waitForEvent(int timeoutMillis)
Waits for event (mouse click or key press) or timeout.
|
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 static final int CLOSE_EVENT
public static final int TIMEOUT_EVENT
public static final int TIMEOUT_FOREVER
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 void drawImage(java.awt.Image image)
image
- bitmap image to drawpublic 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 addSprite(Sprite sprite)
sprite
- public void waitForEvent()
public void waitForEvent(int timeoutMillis)
timeoutMillis
- maximum waiting duration in milliseconds,
if timeoutMillis == TIMEOUT_FOREVER then block until event
if timeoutMillis == 0 then return immediately
if event queue is empty then a TIMEOUT_EVENT is generatedpublic int getEventType()
public char getKey()
public static void delay(int ms)
ms
- the number of milliseconds to waitpublic static void setExitOnLastClose(boolean exitOnLastClose)
exitOnLastClose
- Enables/disables System.Exit(0) on close of last window