ImageItem with default image layout : ImageItem « J2ME « Java Tutorial


import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.midlet.MIDlet;

public class ImageItemLAYOUT_DEFAULT extends MIDlet {
  protected Display display;

  protected void startApp() {
    display = Display.getDisplay(this);

    Form form = new Form("Demo");

    try {
      Image red = Image.createImage("/red.png");
      form.append(new ImageItem("Default", red, ImageItem.LAYOUT_DEFAULT, null));
    } catch (IOException ex) {
      form.append("Failed to load images");

  protected void pauseApp() {

  protected void destroyApp(boolean unconditional) {

31.16.1.ImageItem with Image layout center
31.16.2.ImageItem with image layout left
31.16.3.ImageItem with image layout right
31.16.4.ImageItem with default image layout
31.16.5.Combine ImageItem.LAYOUT_NEWLINE_BEFORE, ImageItem.LAYOUT_CENTER,ImageItem.LAYOUT_NEWLINE_AFTER for ImageItem
31.16.6.Load png image to ImageItem
31.16.7.Use ImageItem in a form