A8: Paint Program

On This Page


What You Will Accomplish

During this assignment, you will:

  • Extend your last assignment by adding a graphical-user interface (GUI)
  • Explore the use of different Swing components in an application
  • Detect mouse events and translate the event into coordinates for drawing shapes

Background Information

For this assignment, you will need to use GUI components to select shapes and colors. Some of the components you can use are:
Component Description Instructions
JButton A basic button How to Use the Common Button API
JCheckBox A check box button How to Use Check Boxes
JComboBox A drop-down box How to Use Combo Boxes
JList Displays items in a column for choosing How to Use Lists
JRadioButton One of a group of radio buttons How to Use Radio Buttons

If you decide to get more creative, you can look in the big list: How to Make/Use...

You will also need to handle mouse events. Java provides two interfaces for mouse events: MouseListener and MouseMotionListener. The textbook has a discussion of mouse event handling in section 13.12.

Specifications

Create an application that lets a user paint a picture. The user must be able to select a shape to draw (e.g. line, rectangle, oval), the color and whether the shape is filled with color. Use either a JRadioButton, JCheckBoxes, JList, or JComboBox to implement each selection.

My suggestion is that you draw on the JFrame and use one or more JPanels as a container for the controls.

Additional requirements are:

  1. Use the mouse to control the size of the shape. To do this, you will need to capture MouseEvents such as MousePressed and MouseReleased. To see how to program a MouseEvent, look at Fig. 13.27 and Fig. 14.4 of the required textbook. If you are using an older textbook, you may want to look at Fig. 13.9.
  2. Provide a JButton to clear the drawing area. You can clear the drawing area by painting it the same color as the background.

Sample Output

This is only an example of one possible program. You can design the layout anyway you like, as long as it is a good user interface and meets the requirements of the instructions.

Extra Credit

The following are worth extra credit points:

  1. Store the shapes drawn in a list, such as an array, so that resizing windows will not erase your drawing. (2 points)
  2. Use your imagination and be creative. (0 to 2 points)

Make certain that your README.txt file lists any extra credit attempted.

Grading Criteria

The instructor will evaluate your assignment using the following criteria. Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive.

Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.

For information on grading policies, including interpretation of scores, see the course Syllabus.

Program Compilation

  • 4: Source code compiles with no errors or warnings
  • 0: Does not compile

Functionality

  • 10: Demonstrates mastery of the assignment
    • Has extra features or demonstrates techniques beyond the assignment
    • Applies concepts from the lessons appropriately
    • Meets all specifications (see above) with particularly elegant solutions
    • No errors encountered during operation
  • 8: Has all the functionality expected of the assignment
    • Demonstrates many techniques from the lesson
    • Meets all specifications (see above)
    • Implementation seems more complicated than necessary.
    • May have one minor error
  • 6: Has most of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets all but one of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have 2-3 minor errors
  • 4: Has some of the functionality expected of the assignment
    • Demonstrates some techniques from the lesson
    • Meets at least 1/2 of the specifications (see above)
    • Implementation seems excessively complicated.
    • May have more than 3 minor errors
  • 2: Serious functional problems but shows some effort and understanding
    • Meets less than 1/2 of the of the specifications (see above)
    • Has a major error or many minor errors
    • Implementation seems very convoluted
    • Demonstrates few techniques from the lesson
  • 0: Does not execute

Program Style

  • 4: Code is well-documented
  • 3: Code has minor documentation errors
    • Has 1 documentation error
  • 2: Code has some documentation errors
    • Has 2-3 documentation errors
  • 1: Code has many documentation errors
    • Has more than 3 documentation errors
  • 0: No apparent attempt to document code

README.txt File

  • 2: README.txt file submitted with specified information included
  • 1: README.txt submitted but some information was not included
  • 0: No README.txt submitted

Maximum Score: 20, plus extra credit

What to Turn In

Submit your assignment following the instructions for homework. Include the following items for grading:

  1. README.txt file
  2. All of your source code (i.e. .java files)
  3. Any other source code needed to make your program function

You must submit all the files needed to make your assignment function properly. Do not assume that the instructors has any files unless explicitly stated by the instructor. Your assignment must work as submitted.

Home | WebCT | Announcements | Schedule | Expectations | Syllabus
Help | FAQ's | HowTo's | Links

Last Updated: November 11 2003 @13:12:56