Graphic Java

Java supports nine logical font names:

  1. Dialog
  2. SansSerif
  3. Serif
  4. Monospaced
  5. Helvetica
  6. TimesRoman
  7. Courier
  8. DialogInput
  9. ZapfDingbats

These names are mapped to a native font used by the underlying windowing system which means that they will look different depending on what system they are viewed on. That is, they may look different on a Debian system than they will on a RedHat or KDE system. They may even look different on different versions of the same system. Students with Windows or Macintosh at home may try this activity at home to see how these systems render these fonts.

The font name is entered as the first argument of the font constructor method:

  Font one = new Font("Courier", Font.PLAIN, 18);
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:
You will recreate the applet shown on this page. When you view your applet using appletviewer, the differences between the fonts may not be displayed. So, you may want to view your applet using Netscape. You will need to create a web page in order to do this. Here's the code for a simple web page which displays an applet (named fonts.class).


See the previous lesson if you have any questions about how to set a font. For this lesson provide an example of each font displayed using Font.PLAIN and a size of 18.