file: screen.java

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

public class screen extends UiApplication {
// main method
public static void main(String[] args) {

screen theApp = new screen();
UiApplication.getUiApplication().pushScreen(new SampleScreen());
theApp.enterEventDispatcher();

}

}

file: SampleScreen.java

import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

//SAMPLE SCREEN
public class SampleScreen extends MainScreen {

public SampleScreen(){

// create a manager and allow scrolling when lots of fields are added
VerticalFieldManager vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL);

// add a label
vfm.add(new LabelField(“First Screen”));

// add vfm to screen
add(vfm);

// show the 2nd screen… run later in EDT…
UiApplication.getApplication().invokeLater(new Runnable(){
public void run(){
SampleScreen2 screen2 = new SampleScreen2();
System.out.println(“About to show screen2”);
UiApplication.getUiApplication().pushScreen(screen2);
System.out.println(“Have already shown screen2”);
}
});

}

}

file: SampleScreen2.java

import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;

// SAMPLE SCREEN2
public class SampleScreen2 extends MainScreen {

public SampleScreen2(){

// create a manager and allow scrolling when lots of fields are added
VerticalFieldManager vfm = new VerticalFieldManager(Manager.VERTICAL_SCROLL);

// add a label
vfm.add(new LabelField(“Second Screen”));

// add vfm to screen
add(vfm);

}

}