Monday, December 10, 2012

Membuat layar splash pada JAVA (J2ME)


import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.IOException;

public class LayarSplash extends MIDlet
  implements CommandListener {
   
  private Display display;
  private Form form;
  private Image image;
  private Alert splash;

  private final Command cmdKeluar =
    new Command("Keluar", Command.EXIT, 1);
 
  public LayarSplash() {
    display = Display.getDisplay(this);
   
    form = new Form("Demo Splash");
    image = null;
    try {
        image = Image.createImage("/icons/Duke.png");     
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
   
    splash = new Alert(null, "  Inisialisasi proses...",
                 image, null);
    splash.setTimeout(7000);
       
    form.addCommand(cmdKeluar);
    form.setCommandListener(this);   
  }
   
  public void startApp() {                
    display.setCurrent(splash, form);
  }
   
  public void pauseApp() {
  }
   
  public void destroyApp(boolean unconditional) {
  }
   
  public void commandAction(Command c, Displayable s) {
    if (c == cmdKeluar) {
      destroyApp(false);
      notifyDestroyed();
    }   
  } 
}

No comments:

Post a Comment