📄 popupbuttons.java
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class PopupButtons extends MIDlet implements CommandListener
{
private Display display;
private Form form;
private Command exit;
private Command process;
private ChoiceGroup item;
private int currentIndex;
private int genderIndex;
private Image img1,img2,img3;
public PopupButtons()
{
try
{
img1=Image.createImage("/1.png");
img2=Image.createImage("/2.png");
img3=Image.createImage("/3.png");
}
catch (Exception e)
{
}
display = Display.getDisplay(this);
item = new ChoiceGroup("Popup", Choice.POPUP);
item.append("Option1", img1);
item.append("Option2", img2);
currentIndex = item.append("Option3", img3);
item.setSelectedIndex(currentIndex, true);
exit = new Command("退出", Command.EXIT, 1);
process = new Command("提交", Command.SCREEN,2);
form = new Form("");
genderIndex = form.append(item);
form.addCommand(exit);
form.addCommand(process);
form.setCommandListener(this);
}
public void startApp()
{
display.setCurrent(form);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command command, Displayable displayable)
{
if (command == exit)
{
destroyApp(false);
notifyDestroyed();
}
else if (command == process)
{
currentIndex = item.getSelectedIndex();
StringItem message = new StringItem("选择的选项是", item.getString(currentIndex));
form.append(message);
form.delete(genderIndex);
form.removeCommand(process);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -