Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

J2ME - HelloWorld

// Example Hello World Java MicroEdition

   1  
   2  import javax.microedition.lcdui.Display;
   3  import javax.microedition.lcdui.Form;
   4  import javax.microedition.midlet.MIDlet;
   5  import javax.microedition.midlet.MIDletStateChangeException;
   6  
   7  public class HelloJ2ME_a1 extends MIDlet
   8  {
   9  	private Display mDisplay;
  10  	private Form mForm;
  11  	
  12  	protected void startApp() throws MIDletStateChangeException
  13  	{
  14  		if(mForm == null)
  15  		{
  16  			// Creo il Form dove inserire il messaggio (questo puo' essere pensato come ad un JFrame)
  17  			mForm = new Form("Hello J2ME !!!");
  18  			
  19  			// Ottengo un Display per la MIDlet
  20  			mDisplay = Display.getDisplay(this);
  21  		}
  22  		
  23  		// Imposto il Form corrente nel Display
  24  		mDisplay.setCurrent(mForm);
  25  	}
  26  
  27  	protected void pauseApp()
  28  	{
  29  
  30  	}
  31  
  32  	protected void destroyApp(boolean arg0) throws MIDletStateChangeException
  33  	{
  34  		// Notifico alla JVM della morte della MIDlet (viene chiamato il Garbage Collector)
  35  		this.notifyDestroyed();
  36  	}
  37  }
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS