Your Names:

6.831 • User Interface Design and Implementation

Massachusetts Institute of Technology
Department of Electrical Engineering and Computer Science
Fall Semester, 2006

AC6: Drawing

The purpose of this activity is to learn more about output and automatic redraw. You will need to download http://courses.csail.mit.edu/6.831/handouts/ac6/ac6-code.zip, which contains the Java code you'll be using. If you use Eclipse, you can create a project directly from the ZIP file using File / Import / Existing Projects into Workspace / Select archive file.

1 Eager Drawing

Look at Problem1.java and draw its view hierarchy below. (Hint: you only need two components.)

Now run Problem1 and click on the window to make the red circle appear. What happens when you move another window over the Problem1 window, then uncover it again? Why does this happen? How would you fix it in the code?

2 More Drawing Problems

Open Problem2.java and run it. Pressing the keyboard arrows should move the circle around the window. What happens? Why does this happen? How would you fix it in the code?

3 Drawing Problems Redux

Open Problem3.java and run it. Clicking on the window should move the circle through a little animation. What actually happens? Why does this happen?

4 Swing Painting Protocol

Find the methods of JComponent that are concerned with painting, and write them down below with a one-line description of each method. Draw arrows to show which methods call each other. If you need help understanding the Swing painting model, you may want to look at Sun's article Painting in AWT and Swing.