Contoh Java Class dan Midlet

Selasa, 28 Februari 2012 Diposting oleh Rizky Romadon 6 komentar
Ini adalah contoh kode Java Class untuk Splashscreen yang saya beri nama kokosplash



import java.io.IOException;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author RIZKY
 */
public class kokosplash extends Canvas {
Image splash;
   
    public kokosplash () throws IOException {
        try {
            splash=Image.createImage("/gambar/splashscreen.png");
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
   
    protected void paint(Graphics g) {
        g.setColor(255,255,255);
        g.fillRect(0,0, getWidth()/2,getHeight()/2);
        g.drawImage(splash,getWidth()/2, getHeight()/2, Graphics.HCENTER | Graphics.VCENTER);
       
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
    


Dan ini adalah Contoh Midletnya

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.IOException;
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.*;
/**
 * @author RIZKY
 */
public class midlet extends MIDlet {
    Display tampilan;
    kokosplash spl;
    public void startApp() {
        tampilan=Display.getDisplay(this);
        try {
            spl=new kokosplash ();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        tampilan.setCurrent (spl);
    }
   
    public void pauseApp() {
    }
   
    public void destroyApp(boolean unconditional) {
    }
}

Selamat Mencoba
jika ada pertanyaan silahkan Komen di Bawah

READ MORE - Contoh Java Class dan Midlet
Label: