例9-3
import java.awt.*;
import java.awt.font.*;
import javax.swing.*;
public class FontSet {
public static void main(String args[]){
FontFrame frame =new FontFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.show();
}
}
class FontFrame extends JFrame{
public FontFrame(){
setTitle("设置字体");
setSize(WIDTH,HEIGHT);
FontPanel panel=new FontPanel();
Container contentPane=getContentPane();
contentPane.add(panel);
}
public static final int WIDTH=300;
public static final int HEIGHT=140;
}
运行结果: