CSE 160
HW #11
Due Thursday April 30, 2009


Reading:
Read Chapter 11 in the Objects First text.  Work along with it, using BlueJ. You will also find the Java Tutorial on Swing to be very helpful.

HW: The first exercise expands on the frame animation diversion we made in class. The second extends the image viewer.

A) Moving Frame.

1) Peruse the JavaDocs for the GUI components discussed in the text and in class, including JFrame, JLabel, JButton, JMenu, etc. With the ImageViewer0.3 from the text book as your starting point, create an application with a frame that has five menus, a label, and a button.  The button says "Go" and the label initially says "Small fast counterclockwise square".
Paste the following method into your class and use it to control the speed.  The try, catch, and exception bits will be explained in a future chapter.

    /**
     * Time delay puts program to sleep, for pause between animation frames
     *
     * @param  n   number of milliseconds to sleep
     */
    public void sleep(int n)
    {
        try  { Thread.sleep(n); }
        catch (Exception e) {} 
    }


You may find the static methods Math.sin and Math.cos to be useful.

For extra credit, add another interesting user-controllable behavior to its motion (but don't eliminate any of the above capabilities).

B) Image Viewer extensions

In CH 11 of the text, do exercises 11.37 (mirror, p. 242) and 11.39 (smoothing, p. 243).

Submit your .jar files for parts A and B.