⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 formtest1.java

📁 《精彩的手机UI例程.zip》是很好的手机编辑软件
💻 JAVA
字号:

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class FormTest1 extends MIDlet implements CommandListener{
    private Form    mainscreen;
    private Command okCommand = new Command("OK", Command.OK, 1);
    private Command exitCommand = new Command("Exit", Command.EXIT, 1);
    private Display display;
	
    public FormTest1() {
        mainscreen= new Form("Form demo");
        mainscreen.addCommand(okCommand);
        mainscreen.addCommand(exitCommand);
        mainscreen.setCommandListener(this);
		
        //first create a stringItem
        mainscreen.append(new StringItem("StringItem Test",
				        "The following is Duke."));

        //create an imageItem
        Image img=null;
        try {
            img= Image.createImage("/Duke.png");
        } catch (Exception e) {}
        mainscreen.append(new ImageItem("ImageItem test",
				        img,
                                        //ImageItem.LAYOUT_NEWLINE_BEFORE|
                                        //ImageItem.LAYOUT_NEWLINE_AFTER|
                                        ImageItem.LAYOUT_CENTER,
				        "Image can not display"));
		
        //create exclusive choice
        String[] editable_choices={"editable", "uneditable"};
        mainscreen.append(new ChoiceGroup("Gauge option",Choice.EXCLUSIVE,
				          editable_choices,null));
        //create a textfield
        mainscreen.append(new TextField("TextField", "", 20, TextField.ANY)); 
 
        //create a datefield
        mainscreen.append(new DateField("DateField", DateField.DATE));
        
        //create a Gauge
        mainscreen.append(new Gauge("Gauge Test",true,100,50));
			
        //retrieve display object 
        display=Display.getDisplay(this);
    }
	
    public void startApp() throws MIDletStateChangeException {
        display.setCurrent(mainscreen);
    }

    /**
     * Pause the MIDlet
     */
    public void pauseApp() {
    }

    /**
     * Called by the framework before the application is unloaded
     */
    public void destroyApp(boolean unconditional) {
        //clear everything
        mainscreen=null;
        okCommand = null;
        exitCommand = null;
        display=null;
    }

    public void commandAction(Command c, Displayable d) {
	if(c==okCommand) {  
	}
	else if(c==exitCommand) {
	    destroyApp(true);
	    notifyDestroyed();
	}
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -