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

📄 prj42.java

📁 非富多彩的十六个J2ME的例子
💻 JAVA
字号:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

public class prj42 extends MIDlet implements CommandListener
{
    Display dis;
    Form frm=new Form("Display Menu");
    //Form frm1=new Form("List product");
    List menu;
    List lst;
    
    TextBox input;
    //Gauge gauge=new Gauge("Your enquiry is being processed",false,10,3);
    
    Command cmdexit=new Command("Exit",Command.EXIT,2);
    Command cmdok=new Command("Ok",Command.OK,1);
    Command cmdback=new Command("Back",Command.BACK,0);
    String currentMenu;
    
    public prj42()
    {
    	
    }
    
    public void startApp() throws MIDletStateChangeException
    {
    	dis=Display.getDisplay(this);
    	menu=new List("Latest products",Choice.IMPLICIT);
    	menu.append("Latest products",null);
    	menu.append("Service call",null);
    	menu.addCommand(cmdexit);
    	menu.setCommandListener(this);
    	
    	lst=new List("Product",Choice.IMPLICIT);
    	lst.append("aa",null);
    	lst.append("bb",null);
    	lst.append("cc",null);
    	lst.addCommand(cmdok);
    	lst.addCommand(cmdback);
    	
    	mainmenu();
   
    
    	
    }
    
    
    
    public void mainmenu()
    {
       dis.setCurrent(menu);
       currentMenu="Main";	
    	
    }
    public void mainlist()
    {
       lst.setCommandListener(this);
       dis.setCurrent(lst);
       currentMenu="list";	
    	
    }
    
     
    public void pauseApp()
    {
    	frm=null;
    
    	dis=null;
    	menu=null;
    	input=null;
    
    }
    
    public void destroyApp(boolean unconditinal ) 
    {
    	
      notifyDestroyed();	
    }
   
    
    public void showtextbox()
    {
        input=new TextBox("Enter the Customer ID:","",20,TextField.ANY);
        input.addCommand(cmdback);
        input.addCommand(cmdok);
        input.setCommandListener(this);
        input.setString("");
        dis.setCurrent(input);
        currentMenu="input";
    }
    
    public void showform()
    {
       frm.addCommand(cmdback);
       frm.setCommandListener(this);
       dis.setCurrent(lst);
       currentMenu="frm";	
    	
    }
  
    
    public void commandAction(Command c,Displayable d) 
    {
   
    	if(c==cmdexit)
    	{
    	  destroyApp(true);
    	}
     
    	else if(c==cmdback)
    	{
    	   if(currentMenu.equals("input")||currentMenu.equals("frm"))
    	   {
    	       mainmenu();	
    	   	
    	   }
    	   
    	   
    	}
    	
    	else
    	{
    	    if(c==cmdok)
    	    {
    	    	
    	       showform();	
    	    }
    	    
    	    else
    	    {
    	       List down=(List)dis.getCurrent();
    	       switch(down.getSelectedIndex())
    	       {
    	           case 0: mainlist();
    	                break;  	               
    	                 
    	           case 1: showtextbox();
    	                 break;	
    	       	
    	       }	
    	    	
    	    }	
    		
    	}
   	
      
    }	
	
}

⌨️ 快捷键说明

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