Now, you should add instructions to your "drawDisplay" method to actually display the numbers used to produce the color of the background on the screen. For now, we will just display this information in black. Later, when you add controls to handle changing the text color this will have to change.
It shouldn't be hard for you to figure out how to place the text:
in the display. The "drawString" method will do the trick. But getting something likeBackground =
where the numbers displayed correspond to the lastest setting of the background color may seem trickier. The secret is that Java gives a special interpretation to the "+" operator when it is used with strings or combinations of strings and numbers. Rather than interpreting "+" as numerical addition, it interprets "+" to mean adding together pieces of text by simply juxtaposing them. If one of the operands of a "+" is a string and the other is a number (int), Java just uses the text that would normally be written to represent the number. As a result, if x and y are integer variables, with current values 25 and 30, the instruction:Background = 200, 0, 200
will displaypen.drawString("( " + x + "," + y + ")" );
on the screen.( 25,30)
Using the "+" operator in this way, add an invocation of "drawString" to "drawDisplay" to include the values of the three color variables that control the background color in the display produced.