Assignment-03a

 

 

 

Foreword

Resources

Code Listings

Foil Sets

Assignments

Solutions

External Resources

SiteMap

Search

Home

Up ] Assignment-01a ] Assignment-01b ] Assignment-01c ] Assignment-01d ] Assignment-02 ] Assignment-02a ] Assignment-03 ] [ Assignment-03a ] Assignment-03b ] Assignment-03c ] Assignment-03d ] Assignment-04 ] Assignment-04a ] Assignment-04b ] Assignment-05 ] Assignment-06 ] Assignment-07 ]

Writing a Java applet with components and layouts

Paint Applet

Here is a simple example of an applet that allows the user to draw graphical shapes on a canvas. Paint.java, the main applet, and DrawCanvas.java.

You can extend this applet in at least two ways:

First of all, you should allow the user to select the current drawing color. This should be done with a list, choice or set of checkboxes.
You should also add some additional drawing functionality: you could add a scribble button that uses mouse dragging to draw wherever the user moves the mouse, or you could add something like drawing a polygon, where the user uses the mouse to click on vertices of the polygon. Or you may have other ideas from other drawing programs.
This applet already has one control panel with buttons. You should add another control panel with your additional controls, so that your version of the program uses another (nested) layout.