Figure 7-32. Select Negative from the Process menu to invert pixel components.
1. Create an AWT application named RandomCircles that presents a can-
vasfordisplayingfilledcircularovals(renderedvia fillOval() ).Anew
randomly colored, randomly positioned, and randomly sized (from 5 to 35
pixels for both the width and height—use the same value for each extent)
filledcircleisdisplayedbythe paint() methodatapplicationstartupand
the canvas. At startup, you might notice that the canvas first displays one
This has to do with AWT invoking the paint() method at least twice at
startup.Becauseyoudon'tknowhowmanytimes paint() willbecalled,
neverrelyon paint() tochangethestateofthecomponent.Instead,you
must only use this method to render the component in response to the cur-
Nimbus Look and Feel before the GUI is created.
3. Swing's AbstractButton class, which JButton extends, declares a
void setMnemonic(int mnemonic) methodforsettingakeyboard
clickingamousebutton.Theargumentpassedto mnemonic isoneofthe
virtual key constants declared in the KeyEvent class (e.g., VK_C ). When
you invoke this method, the first occurrence of the character (from left to
press this key with the current look and feel's mouseless modifier (typic-
TempVerter applicationtoassignthe VK_C mnemonictotheConvertto
Celsius button and the VK_F mnemonic to the Fahrenheit button.
graphics.Createanewversionof SplashCanvas thattakesadvantageof