Troubleshooting guide
238
BlackBerry Java Development Environment Development Guide
package com.rim.samples.docs.countryinfo;
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.*;
import net.rim.device.api.i18n.*;
import com.rim.samples.docs.resource.*;
/* This sample demonstrates how to store text strings in separate resource
files for specific locales rather than providing text strings directly
in the code. In your source code, you retrieve the string from the resource
to display the appropriate text for the user locale. */
public class CountryInfo extends UiApplication {
public static void main(String[] args) {
CountryInfo theApp = new CountryInfo();
theApp.enterEventDispatcher();
}
public CountryInfo() {
pushScreen(new HelloWorldScreen());
}
}
final class HelloWorldScreen extends MainScreen implements CountryInfoResource {
private InfoScreen _infoScreen;
private ObjectChoiceField choiceField;
private int select;
private static ResourceBundle _resources = ResourceBundle.getBundle(
CountryInfoResource.BUNDLE_ID, CountryInfoResource.BUNDLE_NAME);
public HelloWorldScreen() {
super();
LabelField title = new LabelField(_resources.getString(APPLICATION_TITLE),
LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);
add(new RichTextField(_resources.getString(FIELD_TITLE)));
String choices[] = _resources.getStringArray(FIELD_COUNTRIES);
choiceField = new ObjectChoiceField(
_resources.getString(FIELD_CHOICE), choices);
add(choiceField);
}
public boolean onClose() {
Dialog.alert(_resources.getString(CLOSE));
System.exit(0);
return true;
}
private MenuItem _viewItem = new MenuItem(_resources, MENUITEM_VIEW, 110, 10) {
public void run() {
select = choiceField.getSelectedIndex();
_infoScreen = new InfoScreen();
UiApplication.getUiApplication().pushScreen(_infoScreen);
}
};