D&C corp.
MIDlet Tutorial About D&C corp. FER Home PVPRM Home IE Home
Izrada MIDlet aplikacije s Wireless Toolkit alatom ZIP    
Main menu Previous Next
page 4 of 7
   



Pisanje koda

Slijedeći ispis sadrži kod jednostavnog MIDlet-a koji prikazuje listu i rotirajući tekst.

Kopirati kod i prenesti ga u omiljeni tekst editor.

 


		/*--------------------------------------------------
		* TickerDemo.java
		*-------------------------------------------------*/
		import javax.microedition.midlet.*;
		import javax.microedition.lcdui.*;
		
		public class TickerDemo extends MIDlet implements CommandListener
		{
		  private Display display;    // Reference to Display object
		  private List lsProducts;   // Main productlist
		  private Ticker tkSale;     // Ticker of what's on sale
		  private Command cmExit;    // Command to exit the MIDlet
		 
		  public TickerDemo()
		  {
			display = Display.getDisplay(this);
			
			cmExit = new Command("Exit", Command.SCREEN, 1);
		
			tkSale = new Ticker("Current Sale: Torchiere Lamp only $29.00");
		
			lsProducts = new List("Products", Choice.IMPLICIT);
			lsProducts.append("Floor Lamp", null);
			lsProducts.append("Chandelier", null);
			lsProducts.addCommand(cmExit);
			lsProducts.setCommandListener(this);
			lsProducts.setTicker(tkSale);
		  }
		
		  public void startApp()
		  {
			display.setCurrent(lsProducts);
		  }
		
		  public void pauseApp()
		  { 
		  }
		
		  public void destroyApp(boolean unconditional)
		  {
		  }
		
		  public void commandAction(Command c, Displayable s)
		  {
			if (c == cmExit)
			{
			  destroyApp(true);
			  notifyDestroyed();
			}
		  }
		}
		


Main menu Previous Next
 MIDlet Tutorial About D&C corp. FER Home PVPRM Home IE Home