BlackBerry Forums Support Community               

Closed Thread
LinkBack Thread Tools
Old 06-29-2011, 09:51 PM   #1 (permalink)
New Member
Join Date: Jun 2011
Model: 9800
Carrier: carrier?
Posts: 1
Post Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy please help me i cannot even make a buttonlistener properly :(

Please Login to Remove!

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();

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

//add a title to the screen
LabelField title = new LabelField("welcome to tempConverter",

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:", "");

ButtonField submit = new ButtonField("result");

submit.setChangeListener(FieldChangeListener(liste ner));


float g = getNumber(c);
float h = calculate(g);

class ButtonListener implements FieldChangeListener {
public void fieldChanged(Field field, int context) {
ButtonField btn = (ButtonField) field;"" + 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()
return true;

i am getting 3 errors

C:\Program Files\Research In Motion\BlackBerry JDE 6.0.0\bin\ error: cannot find symbol
submit.setChangeListener(FieldChangeListener(liste ner));

C:\Program Files\Research In Motion\BlackBerry JDE 6.0.0\bin\ error: incompatible types
float g = getNumber(c);

C:\Program Files\Research In Motion\BlackBerry JDE 6.0.0\bin\ error: local variable h is accessed from within inner class; needs to be declared final"the temp in F" + h );
Old 06-30-2011, 08:39 AM   #2 (permalink)
BlackBerry Extraordinaire
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default Re: please help me i cannot even make a buttonlistener properly :(

Please read the sticky thread about posting code. The lump you've posted is very difficult to read. Properly formatted code is easier to debug.

A FieldChangeListener is an interface not a class. You can't call the constructor like: FieldChangeListener(listener)

Float and float are not the same type. A Float is a Class, a float is a scalar.

Declare h as final and read about the java final keyword.
My other Blackberry is a PlayBook.
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads for: please help me i cannot even make a buttonlistener properly :(
Thread Thread Starter Forum Replies Last Post
Help Help Help Help With Themes 1llest03 BlackBerry Help 6 02-10-2011 01:39 PM
International warranty - please help vesava General BlackBerry Discussion 1 01-30-2011 07:38 AM
Hardware problem - any help will be appreciate vesava BlackBerry Help 1 01-30-2011 07:37 AM
International warranty - help vesava General 9000 Series Discussion - Bold 2 01-30-2011 07:35 AM
I got a bb 8320 i cant make phonecalls though, HELP! orli General 8300 Series Discussion - Curve 2 10-18-2008 07:12 PM

Copyright 2004-2014
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.