Your application will require two different
classes. One will contain the main
function that creates a JFrame and adds your
specialized JPanel to it. The other will be your specialized JPanel (that extends JPanel).
Let's take a closer look at your specialized JPanel class. It
will have the following form:
public class CoolGamePanel
extends JPanel implements MouseListener
{
//datafields go here
//-need
to keep track of circlex, circley,
circleradius, goodClicks,
badClicks, startTime
//constructor goes here
//-gives initial value to each datafield
//-sets the listener object to this
//paint method goes here
//-we
simply draw circle based on the datafields
//-we stop drawing if 60 seconds have elapsed
//five mandatory MouseListener methods go
here
//-all are blank except the mouseClicked()
method
//-mouseClicked method should update the circle's x, y and
radius and good/bad clicks
//-mouseClicked method needs to be able to determine if
click is on circle or not.
//-mouseClicked method calls repaint()
}
|