// File: TestAwt11.java (Module 9) // // Author: Rahul Simha // Created: October 13, 1998 // // Explores fonts. import java.awt.*; class NewFrame extends Frame { // Constructors. public NewFrame (int width, int height) { // Set the title and other parameters. this.setTitle ("Fonts"); this.setResizable (true); this.setBackground (Color.cyan); this.setSize (width, height); // Show the frame. this.setVisible (true); } // No-parameter constructor - use a default size. public NewFrame () { this (500, 300); } // Override paint(): public void paint (Graphics g) { // Create 10-point Serif fonts in all styles: Font f1 = new Font ("Serif", Font.PLAIN, 10); g.setFont (f1); g.drawString ("Serif-Plain-10pt", 30, 60); f1 = new Font ("Serif", Font.ITALIC, 10); g.setFont (f1); g.drawString ("Serif-Italic-10pt", 30, 90); f1 = new Font ("Serif", Font.PLAIN | Font.BOLD, 10); g.setFont (f1); g.drawString ("Serif-Plain-Bold-10pt", 30, 120); f1 = new Font ("Serif", Font.ITALIC | Font.BOLD, 10); g.setFont (f1); g.drawString ("Serif-Italic-Bold-10pt", 30, 150); // Create 20-point SansSerif fonts in all styles: f1 = new Font ("SansSerif", Font.PLAIN, 20); g.setFont (f1); g.drawString ("SansSerif-Plain-20pt", 140, 60); f1 = new Font ("SansSerif", Font.ITALIC, 20); g.setFont (f1); g.drawString ("SansSerif-Italic-20pt", 140, 90); f1 = new Font ("SansSerif", Font.PLAIN | Font.BOLD, 20); g.setFont (f1); g.drawString ("SansSerif-Plain-Bold-20pt", 140, 120 ); f1 = new Font ("SansSerif", Font.ITALIC | Font.BOLD, 20); g.setFont (f1); g.drawString ("SansSerif-Italic-Bold-20pt", 140, 150); } } public class TestAwt11 { public static void main (String[] argv) { NewFrame nf = new NewFrame (450,200); } }