hi Joseph,
every time you create a new Graphics environment (see the mouseDraaged method)), you get one in its
complete default state, Therefore, in your mouseDragged method, you always
draw first with the default color, black. It is only after you have drawn that you change
the drawing color, Therefore you do not see any impacr whatsoever.
Two other remarks:
the assignment indicates that your buttons should have corresponding colors. Currently,
you are only supplying names on them.
The direct drwing which you do in the mouseDragged method works, but is considered
dubious. Normally, you would do all the painting in a paintComponent() method (you have
systematically outcommented the repainf() command).
Well, this technique works, but it has some drawbacks. First, it lets you draw over your buttons,
although the effect is actually pleasing. If you then click on an overdrawn button, you will see
your lines erased at that button.
Which brings me to the second remark: since you do not paint anything in your paintComponent
method,
you should expect some problems when your frame changes. Now, covering your
frame by some other frame and then uncovering, you won't notice anything. That's because
of the double buffering that
Java uses. However, resize your window and see what happens.
But then, storing all the drawing information such that you can restore everything in the paintComponent,
may be covered in a lesson to come.
Greetz,
Piet