?? fontset.java
字號:
//FontSet
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);
// 將panel加入到frame
FontPanel panel = new FontPanel();
Container contentPane = getContentPane();
contentPane.add(panel);
}
public static final int WIDTH = 300;
public static final int HEIGHT = 200;
}
class FontPanel extends JPanel
{
public void paintComponent(Graphics g)
{
super.paintComponent(g);
//設置字體
Font f = new Font("宋體", Font.BOLD + Font.ITALIC, 20);
g.setFont(f);
//顯示文本
g.drawString(" 你好, Java!", x, y);
}
public int x = 75;
public int y = 100;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -