Window
The parent class for all javaDraw programs, the Window class helps to register events and manages program flow.
Quick Reference can help with small issues or lessen the learning curve, but it can never replace the full documentation which is available here.

Utilization

The first thing you will do in javaDraw is create a class that extends the "Window" class, allowing it to handle input. In order to actually open a visual window on the computer, you will need to call the Window.open() method.
public class Driver extends Window {
public static void main(String[] args) {
Window.open();
}
}
We can then add the start() method to run code when the window opens:
public class Driver extends Window {
public static void main(String[] args) {
Window.open();
}
public void start() {
// ... now we can write some code here!
}
}

Input

The input system in javaDraw is designed to be used in the most simple way possible. Input methods are called asynchronously while the primary program remains on the window thread.
There are many input methods:
public class Driver extends Window {
public static void main(String[] args) {
Window.open();
}
public void mouseDown(int button, Location location) {}
public void mouseUp(int button, Location location) {}
public void mouseDrag(int button, Location location) {}
public void mouseMove(Location location) {}
public void keyDown(Key key) {}
public void keyUp(Key key) {}
}
You can add whichever input methods you need for your program and leave the others out with no issue.
Copy link