📄 fonts.java
字号:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Fonts extends JFrame {
public Fonts()
{
super( "Using fonts" );
setSize( 420, 325 );
show();
}
public void paint( Graphics g )
{
// set current font
// and draw a string
g.setFont( new Font( "楷体", Font.BOLD, 14 ) );
g.drawString( "楷体 14 point bold.", 20, 50 );
// set current font
// italic, 24pt and draw a string
g.setFont( new Font( "黑体", Font.ITALIC, 24 ) );
g.drawString( "黑体 24 point italic.", 20, 90 );
// set current font
// plain, 14pt and draw a string
g.setFont( new Font( "宋体", Font.PLAIN, 16 ) );
g.drawString( "宋体 16 point plain.", 20, 130 );
// set current font
// 18pt and draw a string
g.setColor( Color.red );
g.setFont(
new Font( "宋体", Font.BOLD + Font.ITALIC, 25 ) );
g.drawString( g.getFont().getName() + " " +
g.getFont().getSize() +
" point bold italic.", 20, 170 );
}
public static void main( String args[] )
{
Fonts app = new Fonts();
app.addWindowListener(
new WindowAdapter() {
public void windowClosing( WindowEvent e )
{
System.exit( 0 );
}
}
);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -