passtoapplet.java

来自「Java 入门书的源码」· Java 代码 · 共 31 行

JAVA
31
字号
//Copyright (c) 1998, Arthur Gittleman
//This example is provided WITHOUT ANY WARRANTY either expressed or implied.

/* Uses parameters set in the html file to 
 * specify the font name and size.
 */

import java.awt.*;
import java.applet.Applet;

public class PassToApplet extends Applet {
  private Font font;
  private int size;
  private String fontName;

  public void init() {
    fontName = getParameter("fontName");
    if (fontName==null) fontName = "Serif";
    try {
      size = Integer.parseInt(getParameter("size"));
    }catch(NumberFormatException e) {
      size = 12;
    }
    font = new Font(fontName,Font.BOLD,size);
    setFont(font);
  }
  public void paint(Graphics g) {
    g.drawString("Uses applet parameters",20,70);
  }
}
   

⌨️ 快捷键说明

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