import uwcse.graphics.*; // uw graphics library
/**
* CSC 142 - Lab 1
* Display a circle in a graphics window
*/
public class WindowWithCircle {
// Instance fields
private GWindow window; // graphics window
private Oval circle; // circle in the window
/**
* Construct a graphics window with a circle
*/
public WindowWithCircle() {
// Construct the window
window = new GWindow();
// Construct the circle
circle = new Oval();
// Put the circle in the window
window.add(circle);
// Exit the application when closing the window
window.setExitOnClose();
}
/**
* Display the circle at location (50,50) in the window, counted in pixels
* from the top left corner of the window pane of the window.
* Color the circle in red.
*/
public void modifyCircle() {
// Place the circle at location (50,50)
// The upper left corner of the bounding box of the circle
// is at (50,50)
circle.moveTo(50, 50);
// Color the circle in red
// note: by writing import java.awt.Color at the top of the program
// we could have written Color.red instead.
circle.setColor(java.awt.Color.red);
// Show the modifications
window.doRepaint();
}
/**
* Entry point of the program
*/
public static void main(String[] args) {
WindowWithCircle w = new WindowWithCircle();
w.modifyCircle();
}
}