?? customitemdemo.java
字號:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class CustomItemDemo extends MIDlet
implements CommandListener
{
private TextField text;
private SimpleItem customitem;
private Command exit;
public void startApp() {
text= new TextField("姓名", "", 30, TextField.ANY);
Form form = new Form("SimpleItemMIDlet");
customitem=new SimpleItem("自定義控件");
form.append(customitem);
form.append(text);
exit = new Command("退出", Command.EXIT, 0);
form.addCommand(exit);
form.setCommandListener(this);
Display.getDisplay(this).setCurrent(form);
}
public void pauseApp() {}
public void destroyApp(boolean unconditional) {}
public void commandAction(Command c, Displayable s) {
if (c==exit)
{
destroyApp(false);
notifyDestroyed();
}
}
class SimpleItem extends CustomItem {
public SimpleItem(String title) { super(title); }
// 實現CustomItem的抽象方法
public int getMinContentWidth() { return 100; }
public int getMinContentHeight() { return 60; }
public int getPrefContentWidth(int width) {
return getMinContentWidth();
}
public int getPrefContentHeight(int height) {
return getMinContentHeight();
}
public void paint(Graphics g, int w, int h) {
g.drawRect(0, 0, w - 1, h - 1);
g.setColor(0x000000ff);
g.drawString(text.getString(),0,0,0);
}
public void commandAction(Command c, Item i)
{
repaint();
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -