Java The Complete Reference, Seventh Edition

(Greg DeLong) #1
The first three cases indrawString( )are simple. Each aligns the string that is passed in
lineto the left or right edge or to the center of the column, depending upon the alignment
style. TheLEFTRIGHTcase aligns both the left and right sides of the string. This means that
we need to calculate the remaining whitespace (the difference between the width of the string
and the width of the column) and distribute that space between each of the words. The last
method in this class advances the alignment style each time you click the mouse on the applet’s
window.

Chapter 23: Introducing the AWT: Working with Windows, Graphics, and Text 699

Free download pdf