All our output is produced by our paint method which is called whenever the Java system wants the canvas to be redrawn. Each time our paint method is called, it places a message to the user in the text area we set aside for this purpose. If any alphabetic characters were found in the input area, the paint method proceeds to draw the bar chart. Each bar is a filled rectangle 2 pixels wide. The largest letter frequencies are represented by bars of length 100 pixels drawn in red.
Smaller frequencies have proportionally shorter bars drawn in black.
The 'for' loop in the paint method also adds a list of the most frequently occurring letters to the message we are giving to the user. The succinctness of this example illustrates the power already built in to the Java class libraries. We will explore some more of the library's features in next month's tutorial. Exercise You can test your understanding of this tutorial by making the following modification to the Java program. Prevent the flickering which occurs each time the screen is redrawn.