hello i am a new programming student and i studied my first course for java so i though i will try to do something for blackberry but it turns out its not that east
please help me i am still learning
here and this is my code
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.*;
/*
* BlackBerry applications that provide a user interface
* must extend UiApplication.
*/
public class TempConverter extends UiApplication
{
public static void main(String[] args)
{
//create a new instance of the application
//and start the application on the event thread
TempConverter theApp = new TempConverter();
theApp.enterEventDispatcher();
}
public TempConverter()
{
//display a new screen
pushScreen(new TempConverterScreen());
}
}
//create a new screen that extends MainScreen, which provides
//default standard behavior for BlackBerry applications
final class TempConverterScreen extends MainScreen
{
public TempConverterScreen()
{
//invoke the MainScreen constructor
super();
//add a title to the screen
LabelField title = new LabelField("welcome to tempConverter",
LabelField.FIELD_HCENTER | LabelField.USE_ALL_WIDTH);
setTitle(title);
add(new SeparatorField()); // to add a Separator
//add the text "Hello World!" to the screen
LabelField tempInsert = new LabelField("write temp in C", 0, -1, Field.FIELD_HCENTER); // declared a label and wrote within it
Font fnt = this.getFont().derive(Font.BOLD | Font.ITALIC| Font.ARABIC_SCRIPT); //to set font specification along with arabic script
tempInsert.setFont(fnt); //affix the font to the label tempInsert
add(tempInsert); // add tempInsert to the screen
EditField c = new EditField("temperature:", "");
add(c);
ButtonField submit = new ButtonField("result");
submit.setChangeListener(FieldChangeListener(liste ner));
add(submit);
float g = getNumber(c);
float h = calculate(g);
class ButtonListener implements FieldChangeListener {
public void fieldChanged(Field field, int context) {
ButtonField btn = (ButtonField) field;
Status.show("" + h );
}
}
}
final public Float getNumber(EditField field) {
float floatFromField = Float.parseFloat(field.getText());
Float number = new Float(floatFromField);
return number;
}
final public float calculate(float x){
float r = (x*(9/5))+32;
return r;
}
//override the onClose() method to display a dialog box to the user
//with "Goodbye!" when the application is closed
public boolean onClose()
{
Dialog.alert("goodbye!");
System.exit(0);
return true;
}
}
i am getting 3 errors
C:\Program Files\Research In Motion\BlackBerry JDE 6.0.0\bin\TempConverter.java:54: error: cannot find symbol
submit.setChangeListener(FieldChangeListener(liste ner));
C:\Program Files\Research In Motion\BlackBerry JDE 6.0.0\bin\TempConverter.java:58: error: incompatible types
float g = getNumber(c);
C:\Program Files\Research In Motion\BlackBerry JDE 6.0.0\bin\TempConverter.java:64: error: local variable h is accessed from within inner class; needs to be declared final
Status.show("the temp in F" + h );