The Lightweight User Interface Toolkit

Sep. 22, 2010

Posted by Dias Nurul Arifin under J2ME
0 Comments | Permalink

Di kenal sebagai LWUIT, adalah sebuah framework di mobile programming khususnya untuk j2me untuk memudahkan membuat komponen maupun desain UI-nya, sebenarnya sudah lama sekali framework ini ada, tapi saya baru posting sekarang :p,

Selain kodingnya juga gampang LWUIT ini menyediakan fitur fitur yang tidak ada di j2me, seperti effect fade in, fade out, slide, dll. dan ada  juga custom componen seperti TabbedPane, Container Layout  dll yg belum tersedia di j2me,

Pertama download dulu library LWUIT di sini, untuk menambahkan librarynya tidak saya jelaskan karena di anggap pembaca sudah bisa, hehehe :D,

berikut saya contohkan sedikit source code contoh aplikasi LWUIT.

package r.r.r;
import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import com.sun.lwuit.layouts.BorderLayout;
import com.sun.lwuit.plaf.UIManager;
import com.sun.lwuit.util.Resources;
import java.io.IOException;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
/**
 *
 * @author Dias Nurul Arifin
 */
public class HelloWorld extends MIDlet{
    protected void destroyApp(boolean unconditional) throws MIDletStateChangeException {
    }
    protected void pauseApp() {
    }
    protected void startApp() throws MIDletStateChangeException {
        Display.init(this);
        try {
            Resources r = Resources.open("/r/r/r/LWUITtheme.res");
            UIManager.getInstance().setThemeProps(r.getTheme(r.getThemeResourceNames()[0]));
        } catch (IOException e){
            e.printStackTrace();
        }
        Form form = new Form("Hello");
        form.setLayout(new BorderLayout());
        form.addComponent("Center", new Label("Hello World"));
        form.show();
    }
}

Untuk kodingannya tidak serumit di j2me kan?

Pada kode di atas ada *LWUITtheme.res* ini adalah file resorce untuk Theme UI-nya yang bisa di buat menggunakan Resource Editor yang di ikut sertakan dalam bundle yang telah di download tadi.

dan?..

ini hasilnya, hehhee :D mudahkan?, selamat mencobaa? happy koding.



Post a Comment:
  • HTML Syntax: Allowed