import java.awt.Color; import uwcse.graphics.GWindow; // in the code, GWindow actually // means uwcse.graphics.GWindow import uwcse.graphics.Oval; /** * A first graphics application: a graphics window with a circle * @author CSC 142 */ public class WindowWithCircle { // Use graphics classes from the uw library private GWindow window; private Oval circle, oval; /** * Creates a graphics window with a circle */ public WindowWithCircle() { window = new GWindow(); circle = new Oval(); oval = new Oval(100, 75, 150, 80, Color.RED, true); window.add(circle); window.add(oval); } /** * Swaps the colors of the two ovals */ public void swapColors() { Color c1 = circle.getColor(); Color c2 = oval.getColor(); circle.setColor(c2); oval.setColor(c1); } /** * Entry point of the program */ public static void main(String[] args) { WindowWithCircle w = new WindowWithCircle(); try { Thread.sleep(500); // wait 500 ms } catch (Exception e) { } w.swapColors(); } }