📄 fonts.java
字号:
import java.awt.*;
import java.applet.*;
import bprolog.plc.Plc;
public
class Fonts extends Applet {
/* Run as an application */
public Font ft;
public String fontName;
public int fontSize;
public int fontStyle;
public String str;
public int width;
public int height;
public static void main(String args[]) {
Frame f = new Frame("Fonts");
Fonts font = new Fonts();
font.init();
f.add("Center",font);
f.setSize(321,321);
f.show();
}
public void init(){
Plc.startPlc(new String []{});
Plc goal = new Plc("fonts", new Object[] {this});
Plc.exec("consult('fonts')");
goal.call();
}
public void paint(Graphics g){
g.setFont(ft);
g.drawString(str,10,10);
g.drawString("Width :"+width,10,40);
g.drawString("Height:"+height,10,70);
}
public void setFontAttr(String name, Integer style, Integer size){
System.out.println(name+style+size);
fontName = name;
fontStyle = style.intValue();
fontSize = size.intValue();
}
public void setString(String s){
str = s;
}
public void computeFontMetrics(){
System.out.println("new"+fontName+fontStyle+fontSize);
ft = new Font(fontName,fontStyle,fontSize);
FontMetrics fm = getFontMetrics(ft);
height = fm.getHeight();
width = fm.stringWidth(str);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -