In this lesson, you create a class with a main method that opens a HomeScreen, which contains a title and a status message.
Click OK to create the file. The Application class appears in the JDE window.
class Application extends net.rim.device.api.ui.UiApplication {
public static void main( String[] args )
{
Application instance = new Application();
instance.enterEventDispatcher();
}
Application() {
pushScreen( new HomeScreen() );
}
} |
The HomeScreen class appears in the JDE window.
package myapp;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import java.util.*;
class HomeScreen extends MainScreen {
HomeScreen() {
// Set the window title
LabelField applicationTitle = new LabelField("Hello BlackBerry");
setTitle(applicationTitle);
// Add a label to show application status
_statusLabel = new LabelField( "Status: Started" );
add( _statusLabel );
}
private LabelField _statusLabel;
} |
The _statusLabel is defined as a class variable so that it can be accessed from other parts of the application later.
The BlackBerry simulator launches in a separate window.
A window appears showing the title bar Hello BlackBerry and the status line Status: started.
The simulator terminates.
| Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |