public final class Font extends Object
采用final进行修饰后,不能被其它类继承.
在帮助文档中,没有查到构造方法,说明该方法被屏蔽,如果使用Font对象,不能通过new来实现
在帮助文档中,发现static Font getFont (int face, int style, int size),说明可以采用该方法,获取Font对象.
第一个参数face:
Font.FACE_MONOSPACE:单空格
Font.FACE_SYSTEM:系统
Font.FACE_PROPORTIONAL:均衡
第二个参数style:
Font.STYLE_BOLD:加粗
Font.STYLE_ITALIC:倾斜
Font.STYLE_UNDERLINED:下划线
Font.STYLE_PLAIN:普通
第三个参数size:
Font.SIZE_LARGE:大号字体
Font.SIZE_MEDIUM:中号字体
Font.SIZE_SMALL:小号字体
有了字体对象了,就可以设置StringItem的样式了.
-------------------------------------------------------------------------------
/**
* @作者 Jcuckoo
* @创建日期 2008-11-10
* @版本 V 1.0
*/
public class StringItemFontMIDlet extends MIDlet {
private Display display;
private Form form;
private Font font;
public StringItemFontMIDlet() {
display=Display.getDisplay(this);
form=new Form("StringItem字体测试");
//原始样式
StringItem st0=new StringItem("字体0:","原始显示",Item.PLAIN);
//单空格-加粗-大号字体
font=Font.getFont(Font.FACE_MONOSPACE, Font.STYLE_BOLD, Font.SIZE_LARGE);
StringItem st1=new StringItem("字体1:","单空格/加粗/大号字体",Item.PLAIN);
st1.setFont(font);
//系统-倾斜-中号字体
font=Font.getFont(Font.FACE_SYSTEM,Font.STYLE_ITALIC,Font.SIZE_MEDIUM);
StringItem st2=new StringItem("字体2","系统/倾斜/中号字体",Item.PLAIN);
st2.setFont(font);
//均衡-下划线-小号字体
font=Font.getFont(Font.FACE_PROPORTIONAL,Font.STYLE_UNDERLINED,Font.SIZE_SMALL);
StringItem st3=new StringItem("字体3","均衡/下划线/小号字体",Item.PLAIN);
st3.setFont(font);
//单空格-下划线-小号字体
font=Font.getFont(Font.FACE_MONOSPACE,Font.STYLE_UNDERLINED,Font.SIZE_SMALL);
StringItem st4=new StringItem("字体4","单空格/下划线/小号字体",Item.PLAIN);
st3.setFont(font);
form.append(st0);
form.append(st1);
form.append(st2);
form.append(st3);
form.append(st4);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
display.setCurrent(form);
}
}
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/guoquanyou/archive/2008/11/10/3265531.aspx