package result;
import java.awt.*;
import javax.swing.*;
class MyCanvas extends Canvas{
String[] FONTS = {"Dialog","DialogInput","Monospaced","Serif","ScanSerif"};
String TEXT = "一个逻辑字体的示例";
public MyCanvas() {
// TODO Auto-generated constructor stub
setSize(300,300);
}
public void paint(Graphics g) {
for (int i = 0; i < FONTS.length; i++) {
g.setFont(new Font(FONTS[i],Font.PLAIN,12));
g.drawString(FONTS[i]+"(plain):"+TEXT,10,20*i+40);
}
for (int i = 0; i < FONTS.length; i++) {
g.setFont(new Font(FONTS[i],Font.BOLD,14));
g.drawString(FONTS[i]+"(bold,italics):"+TEXT, 10, 20*i+180);
}
}
}
public class F8 extends JFrame{
public F8() {
super("字体");
setSize(300,300);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
add(new MyCanvas());
validate();
}
public static void main(String[] args) {
new F8();
}
}
package result;
import java.awt.*;import javax.swing.*;class MyCanvas extends Canvas{String[] FONTS = {"Dialog","DialogInput","Monospaced","Serif","ScanSerif"};String TEXT = "一个逻辑字体的示例";public MyCanvas() {// TODO Auto-generated constructor stubsetSize(300,300);}public void paint(Graphics g) {for (int i = 0; i < FONTS.length; i++) {g.setFont(new Font(FONTS[i],Font.PLAIN,12));g.drawString(FONTS[i]+"(plain):"+TEXT,10,20*i+40);}for (int i = 0; i < FONTS.length; i++) {g.setFont(new Font(FONTS[i],Font.BOLD,14));g.drawString(FONTS[i]+"(bold,italics):"+TEXT, 10, 20*i+180);}}}public class F8 extends JFrame{public F8() {super("字体");setSize(300,300);setVisible(true);setDefaultCloseOperation(EXIT_ON_CLOSE);add(new MyCanvas());validate();}public static void main(String[] args) {new F8();}}