6.831 • User Interface Design and Implementation

Massachusetts Institute of Technology
Department of Electrical Engineering and Computer Science
Spring Semester, 2008

AC6: Output

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

Run Problem1.java 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? (If you're using a Mac, you'll see different behavior than a Windows user will. Look at a Windows box to see the effect we're interested in.)

Why does this happen? How would you fix it in the code?

2 More Drawing Problems

Run Problem2.java. 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 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.