www.pudn.com > Jie.rar > Jie.java


import javax.microedition.lcdui.*; 
import javax.microedition.midlet.*; 
import javax.microedition.midlet.MIDletStateChangeException; 
 
public class Jie extends MIDlet implements CommandListener{ 
   private Image pic; 
   private List list; 
   private List listmovie; 
   private List listall; 
   private List listother; 
   private List listtv; 
   private List listori; 
   private Display display; 
   private Displayable cd; 
    
   private final TextBox text=new TextBox("CCTV1","No singal,please try again~~",30,TextField.ANY); 
    
   private Ticker ticker; 
    private Form form; 
     
    private final Command exit=new Command("退出",Command.EXIT,1); 
    private final Command back=new Command("返回",Command.BACK,1); 
    private final Command ok=new Command("进入",Command.OK,1); 
     
 
	public Jie() { 
		cd=new Can(); 
		cd.addCommand(ok); 
		cd.addCommand(back); 
		cd.setCommandListener(this); 
		 
		 display=Display.getDisplay(this); 
		try{  
			pic=Image.createImage("/logo2.png"); 
		}  
		catch(Exception e) 
		{ 
		} 
		form=new Form(null); 
		ticker=new Ticker("Welcome to heiro!"); 
		form.append(pic); 
		form.setTicker(ticker); 
		form.addCommand(ok); 
		form.addCommand(exit); 
		form.setCommandListener(this); 
		 
		 
		 
		list=new List("			             Program Menu:",List.EXCLUSIVE); 
		list.append("全部",null); 
		list.append("电影",null); 
		list.append("电视",null); 
		list.append("原创",null); 
		list.append("其它",null); 
		list.addCommand(ok); 
		list.addCommand(back); 
		list.setCommandListener(this); 
		 
		listall=new List("                   All programs:",List.EXCLUSIVE); 
		listall.append("CCTV1",null); 
		listall.append("CCTV2",null); 
		listall.append("CCTV5",null); 
		listall.append("CCTV6",null); 
		listall.append("凤凰卫视",null); 
		listall.addCommand(ok); 
		listall.addCommand(back); 
		listall.setCommandListener(this); 
		 
		list=new List("						Program Menu:",List.EXCLUSIVE); 
		list.append("全部",null); 
		list.append("电影",null); 
		list.append("电视",null); 
		list.append("原创",null); 
		list.append("其它",null); 
		list.addCommand(ok); 
		list.addCommand(back); 
		list.setCommandListener(this); 
		 
		text.addCommand(back); 
		text.setCommandListener(this); 
		 
		 
		} 
		 
	 
		// TODO Auto-generated constructor stub 
	 
 
	protected void destroyApp(boolean arg0) throws MIDletStateChangeException { 
		// TODO Auto-generated method stub 
      form=null; 
      pic=null; 
	} 
 
	protected void pauseApp() { 
		// TODO Auto-generated method stub 
 
	} 
 
	protected void startApp() throws MIDletStateChangeException { 
		display.setCurrent(form); 
 
	    display.flashBacklight(30000); 
		 
		// TODO Auto-generated method stub 
 
	} 
	public void commandAction(Command cmd,Displayable d) 
	{   if(d.equals(form)) 
	   { 
		  if(cmd==exit) 
		   { 
		  try{ 
		   destroyApp(true); 
		   } catch (Exception e) 
		   {	 
		   } 
		   notifyDestroyed(); 
		   } 
		if(cmd==ok) 
		{ 
			display.setCurrent(list); 
			  
	    
	    } 
	   }  
	    if(d.equals(list)) 
	    {   if(cmd==ok){ 
	    	switch (((List)d).getSelectedIndex()){ 
	    	case 0:   
				Display.getDisplay(this).setCurrent(listall); 
	    	case 1: 
	    		Display.getDisplay(this).setCurrent(listmovie); 
	    	case 2: 
	    		Display.getDisplay(this).setCurrent(listtv); 
	    	case 3: 
	    		Display.getDisplay(this).setCurrent(listori); 
	    	case 4: 
	    		Display.getDisplay(this).setCurrent(listother); 
	    		 
	    }} 
	       if(cmd==back) 
	    	   Display.getDisplay(this).setCurrent(form); 
	    } 
	    	    
	    if(d.equals(listall)) 
	    { if(cmd==ok) 
	    	switch (((List)d).getSelectedIndex()){ 
    	case 0:   
			Display.getDisplay(this).setCurrent(cd); 
			 
    	case 1: 
    		Display.getDisplay(this).setCurrent(listmovie); 
    	case 2: 
    		Display.getDisplay(this).setCurrent(listtv); 
    	case 3: 
    		Display.getDisplay(this).setCurrent(listori); 
    	case 4: 
    		Display.getDisplay(this).setCurrent(listother); 
    		 
    } 
	      if(cmd==back) 
	    	  Display.getDisplay(this).setCurrent(list); 
	      } 
	     
	    if(d.equals(cd)) 
	    { if(cmd==back) 
			Display.getDisplay(this).setCurrent(listall); 
	      if(cmd==ok) 
	    	  Display.getDisplay(this).setCurrent(text); 
	    } 
	   if(d.equals(text)) 
	   { if(cmd==back) 
		   Display.getDisplay(this).setCurrent(cd); 
	   } 
	     
	     
	} 
 
}