📄 appearancemode.java
字号:
import java.io.IOException;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.Item;
import javax.microedition.lcdui.ItemCommandListener;
import javax.microedition.lcdui.StringItem;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class AppearanceMode extends MIDlet implements ItemCommandListener{
Display display = null;
Form form = new Form("显示模式演示");
ImageItem ii = null;
StringItem si = null;
public AppearanceMode() {
super();
Command cmdSelect = new Command("选择", Command.ITEM, 1);
si = new StringItem("这是标签:",
"这是内容",
Item.BUTTON);
si.addCommand(cmdSelect);
si.setItemCommandListener(this);
form.append(si);
Image img = null;
try {
img = Image.createImage("/boat.png");
} catch (IOException e) {
e.printStackTrace();
}
if (img != null) {
ii = new ImageItem("这是标签:", //标签
img, //要显示的图像
Item.LAYOUT_CENTER | //布局居中
Item.LAYOUT_NEWLINE_BEFORE |
Item.LAYOUT_EXPAND,
null, //图像不能显示时的提示文字
Item.BUTTON); //表面模式
ii.addCommand(cmdSelect);
ii.setItemCommandListener(this);
form.append(ii);
}
}
protected void startApp() throws MIDletStateChangeException {
display = Display.getDisplay(this);
display.setCurrent(form);
}
protected void pauseApp() {
// TODO 自动生成方法存根
}
protected void destroyApp(boolean arg0)
throws MIDletStateChangeException {
// TODO 自动生成方法存根
}
public void commandAction(Command c, Item item) {
if (item == si) {
si.setLabel("文本按钮被按下了!");
si.setLayout(Item.LAYOUT_EXPAND);
} else if (item == ii) {
ii.setLabel("图形按钮被按下了!");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -