_rdsTextField.setLabel("RDS: ");
_logTextField = new TextField(Field.NON_FOCUSABLE);
_logTextField.setLabel("Log: ");
_playButton.setCommand(new Command(new CommandHandler() {
public void execute(final ReadOnlyCommandMetadata data,
final Object context) {
// Check whether the Player has already been started
if (_fmRadioDemoPlayer.getPlayerState() == Player.STARTED) {
_fmRadioDemoPlayer.switchRbds(false);
_fmRadioDemoPlayer.stopPlayer();
_playButton.setLabel("Play");
} else {
_fmRadioDemoPlayer.startPlayer();
_fmRadioDemoPlayer.switchRbds(true);
_playButton.setLabel("Stop");
}
}
}));
_seekDownButton.setCommand(new Command(new CommandHandler() {
public void execute(final ReadOnlyCommandMetadata data,
final Object context) {
try {
final int frequency =
stringToFrequency(_frequencyTextField.getText());
_fmRadioDemoPlayer.seek(frequency, false);
_frequencyTextField
.setText(frequencyToString(_fmRadioDemoPlayer
.getFrequency()));
} catch (final NumberFormatException n) {
// If the TextField cannot be parsed as a valid frequency,
// set the TextField text to a valid frequency.
_frequencyTextField
.setText(frequencyToString(INITIAL_FREQUENCY));
}
}
}));
_seekUpButton.setCommand(new Command(new CommandHandler() {
public void execute(final ReadOnlyCommandMetadata data,
final Object context) {
try {
final int frequency =
stringToFrequency(_frequencyTextField.getText());
_fmRadioDemoPlayer.seek(frequency, true);
_frequencyTextField
.setText(frequencyToString(_fmRadioDemoPlayer
.getFrequency()));
} catch (final NumberFormatException n) {
// If the TextField cannot be parsed as a valid frequency,
// set the TextField text to a valid frequency.
_frequencyTextField
.setText(frequencyToString(INITIAL_FREQUENCY));
}
}
}));
_increaseRSSIButton.setCommand(new Command(new CommandHandler() {
public void execute(final ReadOnlyCommandMetadata data,
final Object context) {
// Increase the internally stored value
// for RSSI that is used for seeking.
_fmRadioDemoPlayer.increaseRSSI();
_rssiLabel.setText(_fmRadioDemoPlayer.getRSSI());
}
}));
_decreaseRSSIButton.setCommand(new Command(new CommandHandler() {
public void execute(final ReadOnlyCommandMetadata data,
final Object context) {
// Decrease the internally stored value
// for RSSI that is used for seeking.
_fmRadioDemoPlayer.decreaseRSSI();
_rssiLabel.setText(_fmRadioDemoPlayer.getRSSI());
}
}));
_setFrequencyButton.setCommand(new Command(new CommandHandler() {
public void execute(final ReadOnlyCommandMetadata data,
final Object context) {
try {
final String text = _frequencyTextField.getText();
if (text.indexOf(".") > -1) {