There are three choices which can be used as the second parameter of the
Font constructor:
Font.PLAIN Font.BOLD Font.ITALICHere's how the student should set up this activity. First declare three instances of the font class at the beginning of the paint method like this:
public void paint(Graphics g){ Font b = new Font("TimesRoman", Font.BOLD, 14); Font p = new Font("TimesRoman", Font.PLAIN, 14); Font i = new Font("TimesRoman", Font.ITALIC, 14);Once these declarations have been made they can be used as needed. For instance:
g.setFont(b);will set the font to bold.
EXAMPLE: This applet is an approximation of what the student will be expected to create. No code will be offered since the student will need to experiment with the use of the setFont method and the font class constructor in order to successfully complete this activity. |
x |
ASSIGNMENT:
The student will create an applet which displays five sentences. Each
sentence should contain two nouns and a verb. The nouns should be displayed
in bold, the verbs should be displayed in italics and all other words should
be displayed in plain. Each sentence should contain a minimum of five words.
ASSIGNMENT RECALL: This assignment is a royal pain in the neck and so you only have to do two lines as specified (instead of five lines).