Contoh Java Class dan Midlet

Selasa, 28 Februari 2012 Diposting oleh Rizky Romadon
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

Label:
  1. Java Class itu apa ya ?

  2. bisa di katakan kategori java mas

  3. Ane gag ngerti gan.. :)

    Blogwalking, salam kenal n sukses selalu aja yah.. :)

    Salam Najibblog2010 dari DBP

  4. mampir ya gan di http://jati-irwan.blogspot.com

    Blogwalking neh :P

Posting Komentar