📄 center.java
字号:
//Copyright (c) 1998, Arthur Gittleman
//This example is provided WITHOUT ANY WARRANTY either expressed or implied.
// Debuging Exercise 7.8 -- Has Errors
import java.awt.*;
import java.applet.Applet;
public class Center extends Applet {
Font f;
String s;
int x, w;
public void init() {
f = new Font("Monospaced",Font.PLAIN,18);
setFont(f);
FontMetrics metrics = getFontMetrics(f);
s = f.getName();
w = metrics.stringWidth(s);
}
public void paint(Graphics g) {
Dimension d = getSize();
int x = w-d.height;
g.drawString(s,x,50);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -