*/
public SpellCheckDemoScreen(final SpellCheckDemo app) {
_app = app;
// Add UI components to the screen.
setTitle(new LabelField("Spell Check Demo", DrawStyle.ELLIPSIS
| Field.USE_ALL_WIDTH));
final RichTextField infoField =
new RichTextField(
"Type a misspelled word into the test field (eg. blackbery). Select menu items to perform spell check operations.",
Field.NON_FOCUSABLE);
add(infoField);
final SeparatorField separator = new SeparatorField();
add(separator);
_testField = new TestField("Test Field: ", "");
add(_testField);
_spellCheckItem =
new MenuItem(new StringProvider("Spell check"), 0x230010, 1);
_spellCheckItem.setCommand(new Command(new CommandHandler() {
/**
* Checks the spelling in the TestField.
*
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
if (_testField.getText().length() == 0) {
Dialog.alert("Test field cannot be empty");
} else {
_app.spellCheck(_testField);
}
}
}));
_learnWordItem =
new MenuItem(new StringProvider("Learn word"), 0x230020, 1);
_learnWordItem.setCommand(new Command(new CommandHandler() {
/**
* Learns the word in the TestField.
*
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
if (_testField.getText().length() == 0) {
Dialog.alert("Test field cannot be empty");
} else {
_app.learnWord(_testField.getText());
}
}
}));
_learnCorrectionItem =
new MenuItem(new StringProvider("Learn correction"), 0x230030,
2);
_learnCorrectionItem.setCommand(new Command(new CommandHandler() {
/**
* Shows the user a list of possible corrections for the word in the
* TestField.
*
* @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
* Object)
*/
public void execute(final ReadOnlyCommandMetadata metadata,
final Object context) {
if (_testField.getText().length() == 0) {
Dialog.alert("Test field cannot be empty");
} else {
final VerticalFieldManager vfm = new VerticalFieldManager();
_popUp = new PopupScreen(vfm);
final LabelField popUpLabel =
new LabelField("Correction for "
+ _testField.getText() + ":");
_correction = new EditField();
_popUp.add(popUpLabel);
_popUp.add(_correction);
final HorizontalFieldManager hfm =