⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fontdemo.java

📁 Java the UML Way 书中所有源码
💻 JAVA
字号:
/*
 * FontDemo.java   E.L. 2001-08-30
 */

import javax.swing.*;
import java.awt.*;

public class FontDemo extends JApplet {
  public void init() {
    Container content = getContentPane();
    Drawing aDrawing = new Drawing();
    content.add(aDrawing);
  }
}

class Drawing extends JPanel {
  public void paintComponent(Graphics window) {
    super.paintComponent(window);
    window.drawString("This is written with the default font", 40, 60);
    Font theFont = new Font("SansSerif", Font.BOLD, 16);
    window.setFont(theFont);
    window.drawString("This is written with the " + theFont.getName() + " font", 40, 100);
    theFont = new Font("Monospaced", Font.ITALIC, 16);
    window.setFont(theFont);
    window.drawString("This is written with the " + theFont.getName() + " font", 40, 140);
    theFont = new Font("Dialog", Font.BOLD + Font.ITALIC, 16);
    window.setFont(theFont);
    window.drawString("This is written with the " + theFont.getName() + " font", 40, 180);
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -