file: TesUI1.java
package ui;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
public class TesUI1 extends UiApplication {
public static void main(String[] args) {
TesUI1 tempUI = new TesUI1();
tempUI.enterEventDispatcher();
}
public TesUI1() {
pushScreen(new contohUIScreen());
}
}
final class contohUIScreen extends MainScreen {
public contohUIScreen() {
super();
// Pemberian judul Aplikasi di MainScreen
LabelField judul = new LabelField(“CONTOH UI”, LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(judul);
// Komponen UI untuk Contoh Pembuatan Label
add(new LabelField(“Label”));
add(new LabelField(“Label 2”, 0, -1, Field.FIELD_RIGHT));
LabelField label = new LabelField(“Label 3”, 0, -1, Field.FIELD_HCENTER);
Font aturHuruf = this.getFont().derive(Font.BOLD | Font.ITALIC);
label.setFont(aturHuruf);
add(label);
add(new SeparatorField()); // pembatas
// Komponen UI untuk Contoh Pembuatan EditField
EditField editbox = new EditField(“Username: “, “”);
add(editbox);
// Komponen UI untuk Contoh Pembuatan PasswordEditField
PasswordEditField passwordbox = new PasswordEditField(“Password: “, “”);
add(passwordbox);
add(new SeparatorField()); // pembatas
// Komponen UI untuk Contoh Pembuatan BitmapField
Bitmap gambar = Bitmap.getBitmapResource(“TesUI1/com/res/1278536638_robot.png”);
BitmapField tampgbr = new BitmapField(gambar, BitmapField.FOCUSABLE);
add(tampgbr);
add(new SeparatorField()); // pembatas
// Komponen UI untuk Contoh Pembuatan ButtonField
ButtonField tombol = new ButtonField(“Tombol”);
ButtonField tombol2 = new ButtonField(“Tombol 2”);
add(tombol);
add(tombol2);
}
public boolean onClose() {
Dialog.alert(“Salam Hangat!”);
System.exit(0);
return true;
}
}