Your Names:

6.831 • User Interface Design and Implementation

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

AC15: Undo

The purpose of this activity is to learn more about implementing undo. You will need to download, 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 Undo in a Text Editor

Open and run it. You should see a Swing text editor with some text already in it. The editor supports the usual text editing commands, plus Control-Z for undo and Control-Y for redo. Experiment with the editor to answer the following questions.

What is the granularity of undo -- i.e., how many user actions are undone by a single Ctrl-Z? Compare it to the undo granularity of another text editor on your computer (like Eclipse or Emacs).

Find a case where one user action in Problem1 needs two presses of Ctrl-Z to undo it.

What kinds of user actions are omitted from Problem1's undo history?

When an action is undone, what parts of the previous user interface state are actually recovered by the undo?

How long (roughly) is Problem1's undo history?

2 Undoing the Scrollbar

Open Problem2 is a subclass of Problem1 in which we want to add scrolling actions to the undo history, but it's currently incomplete. Fill in the parts marked YOUR CODE HERE so that Ctrl-Z and Ctrl-Y undo and redo a change to the scrollbar. Write the code you added here:

Test your solution by pressing the scrollbar's down arrow several times, and then try to undo what you did. What happens? Why? Fix the problem.

Now test by dragging the scrollbar thumb, and then try to undo the drag. What is the granularity of undo when you drag?

Change the program so that dragging the thumb only adds one change to the undo history, when the thumb is finally released. (Hint: the AdjustmentEvent has a method getValueIsAdjusting() that tells you whether the user is still dragging the thumb.)