Skip to content

Instantly share code, notes, and snippets.

@fcflyinsky
Created February 18, 2014 09:42
Show Gist options
  • Save fcflyinsky/9067670 to your computer and use it in GitHub Desktop.
Save fcflyinsky/9067670 to your computer and use it in GitHub Desktop.
import java.applet.Applet;
import java.awt.*;
public class Ex13_103 extends Applet {
public void init() {
// 設定Applet背景顏色
this.setBackground(Color.black);
// 設定Applet前景(繪圖)顏色
this.setForeground(Color.white);
}
public void paint(Graphics g) {
// 畫出字串內容。
// g.drawString(字串,基準x,基準x)
g.drawString("預設字體", 50, 50);
// 設定字體格式。new Font(字體名稱,字體樣式,字體大小)
g.setFont(new Font("標楷體", Font.ROMAN_BASELINE, 30));
g.drawString("字體為標楷,大小為30", 50, 100);
// 設定字體格式。new Font(字體名稱,字體樣式,字體大小)
g.setFont(new Font("細明體", Font.ROMAN_BASELINE, 14));
g.drawString("字體為細明,大小為14", 50, 150);
// 更改狀態列文字
showStatus("繪圖視窗");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment