Pixel Poker

Supporting files: None.

Objectives:

When editing images, particularly small icons, an application for editing individual pixels can be quite useful. Changing an individual memory value is sometimes called poking, hence the name of this assignment: Pixel Poker. The following illustrates how the program should look when it is executed.

We have a 16x16 grid, each representing a single pixel of an image. Initially all elements of the grid are blue, but when the user clicks on a blue element, it will become yellow; and when the user clicks on a yellow element, it turns back to blue.

Your JFrame's container will use a GridLayout, and each individual element within the grid will be a JPanel. You can set the color of a JPanel by passing a Color object to the setBackground method, and you can access its current color using getBackground. You will want to associate a MouseListener with each JPanel to identify when the user presses the mouse button in the panel.

The completed assignment uses the following classes and interfaces:

Classesjavax.swingJFrame
javax.swingJPanel
java.awtContainer
java.awtGridLayout
java.awtColor
java.awt.eventMouseEvent
Interfacesjava.awt.eventMouseListener