file: start.java

package package_screen;

import net.rim.device.api.ui.UiApplication;

public class start extends UiApplication {

public start() {
Screen_Main SCREEN = new Screen_Main();
//Screen_Main1 SCREEN = new Screen_Main1();
//Screen_Main2 SCREEN = new Screen_Main2();
pushScreen(SCREEN);
}

public static void main(String args[]) {
start APP = new start();
APP.enterEventDispatcher();
}
}

file: Screen_Main.java

package package_screen;

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.component.BitmapField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.decor.Background;
import net.rim.device.api.ui.decor.BackgroundFactory;

public class Screen_Main extends MainScreen {

private VerticalFieldManager _manager;
private Bitmap               objBitmap;

public Screen_Main() {

//change background color
_manager = (VerticalFieldManager)getMainManager();
objBitmap = Bitmap.getBitmapResource( “blue_grad_background.png”);

//Background bg = BackgroundFactory.createLinearGradientBackground(Color.AQUA, Color.ALICEBLUE, Color.BEIGE, Color.BLANCHEDALMOND);
//Background bg = BackgroundFactory.createSolidBackground(Color.BLUE);
Background bg = BackgroundFactory.createBitmapBackground(objBitmap);
_manager.setBackground(bg);

//Field Manager//

//Pengaturan Layout Vertical//
VerticalFieldManager titleIcon = new VerticalFieldManager(Field.USE_ALL_WIDTH);
VerticalFieldManager titleText = new VerticalFieldManager(Field.USE_ALL_WIDTH | Field.USE_ALL_HEIGHT);

//Pengaturan Layout Horizontal//
HorizontalFieldManager ICON = new HorizontalFieldManager(Field.FIELD_HCENTER);
HorizontalFieldManager TEXT = new HorizontalFieldManager(Field.FIELD_HCENTER);
HorizontalFieldManager TEXT2 = new HorizontalFieldManager(Field.FIELD_HCENTER);
HorizontalFieldManager TEXT3 = new HorizontalFieldManager(Field.FIELD_HCENTER);

//Menambahkan Icon//
titleIcon.add(ICON);

//Menambahkan Text//
titleText.add(TEXT);
titleText.add(TEXT2);
titleText.add(TEXT3);

//Bitmaps//
BitmapField titleBitmap = new BitmapField(Bitmap.getBitmapResource(“Firefox.png”));
ICON.add(titleBitmap);

//Labels//
LabelField Text = new LabelField(“Wahyu Kurniawan”) {
public void paint(Graphics g){
g.setColor(Color.SALMON);
super.paint(g);
}
};

LabelField Text2 = new LabelField(“http://www.wahyukurniawan.info”) {
public void paint(Graphics g){
g.setColor(Color.WHITE);
super.paint(g);
}
};

LabelField Text3 = new LabelField(“Best viewed with Mozilla Firefox”) {
public void paint(Graphics g){
g.setColor(Color.BLUEVIOLET);
super.paint(g);
}
};

//Setting Font Style
Font style1 = this.getFont().derive(Font.BOLD | Font.ITALIC);
Font style2 = this.getFont().derive(Font.BOLD);
Text.setFont(style1);
Text2.setFont(style2);

// Pemberian judul Aplikasi di MainScreen
LabelField judul = new LabelField(“CONTOH BLACKBERRY UI”, LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(judul);

TEXT.add(Text);
TEXT2.add(Text2);
TEXT3.add(Text3);

//Initialize the Screen//
add(titleIcon);
add(titleText);

}

}

file: Screen_Main1.java

package package_screen;

import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.ListField;
import net.rim.device.api.ui.component.ListFieldCallback;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Manager;

public class Screen_Main1 extends MainScreen
implements ListFieldCallback {

String Data[] = {“Task ID”,”Priority”,”Task Name”,”Location”,”Task Type”,”State”,”AAA”,”BBB”,”CCCC”,”DDD”,”EEE”,”FFFF”,”GGGG”,”HHHH”,”IIII”};

private VerticalFieldManager objManager;
private Bitmap               objBitmap;

ListField objList = null;

public Screen_Main1(){
super();
drawComponent();
setTitle( “Inbox Screen” );

objBitmap = Bitmap.getBitmapResource( “blue_grad_background.png”);

objManager = new VerticalFieldManager( Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR ) {
protected void paint( Graphics g ){
int y = Screen_Main1.this.getMainManager().getVerticalScroll();

g.drawBitmap( 0, y, objBitmap.getWidth(), objBitmap.getHeight(), objBitmap, 0, 0 );
super.paint( g );
}

protected boolean keyDown( int keycode, int status ){
invalidate();
return super.keyDown( keycode, status );
}

protected boolean navigationMovement( int dx, int dy, int status, int time ){
invalidate();
return super.navigationMovement( dx, dy, status, time );
}

protected int moveFocus(int amount, int status, int time){
invalidate();
return super.moveFocus(amount, status, time);
}

};

add(objList);

super.add( objManager );
}

public void add( Field field ){
objManager.add( field );
}

public void delete( Field field ){
objManager.delete( field );
}

public void drawListRow(ListField listField, Graphics g, int index, int y, int width){
g.drawText(Data[index], /*10*/10, /*CTIAMain.ROW_HEIGHT*index*/y );
}

public int indexOfList(ListField listField, String prefix, int start){

return 0;
}

public Object get(ListField listField, int index){
return Data[index];
}

public int getPreferredWidth(ListField listField){
return 0;
}

private void drawComponent(){

objList = new ListField(Data.length);
objList.setCallback(this);

}

}

file: Screen_Main2.java

package package_screen;

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.ui.decor.*;

public class Screen_Main2 extends MainScreen {

private VerticalFieldManager _manager;

Screen_Main2() {
_manager = (VerticalFieldManager)getMainManager();

Background bg = BackgroundFactory.createSolidBackground(Color.RED);
_manager.setBackground(bg);

XYEdges edges = new XYEdges(20, 20, 20, 20);
Border border = BorderFactory.createBevelBorder(edges);
_manager.setBorder(border);

_manager.add(new LabelField(“test”));
_manager.add(new LabelField(“test 1”));
_manager.add(new LabelField(“test 3”));

}
}