Monday, 16 January 2012



J2ME program form displaying an Image

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

public class img extends MIDlet
{
private Display display;
private Form fmMain;
 public img()
 {
  display = Display.getDisplay(this);
  fmMain = new Form("dis_img");
 }
public void startApp()
{
try
{
Image im = Image.createImage("/Sunset.jpg");
fmMain.append(new ImageItem(null, im, ImageItem.LAYOUT_CENTER , null));
display.setCurrent(fmMain);
}
catch (java.io.IOException e)
{
System.err.println("Unable to locate or read .jpg file");
}
}
public void pauseApp(){}
public void destroyApp(boolean unconditional){}
}


Output: -

Related Posts :



0 comments:

Confused? Feel free to ask

Post a Comment