Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    Jan 2009
    Posts
    160
    Thanks
    40
    Thanked 1 Time in 1 Post

    Question J2ME converter program not accepting user input

    I am having problems with my converter program not accepting the value the user inputs. Everything seems so right but the result is always as if the user entered nothing. If anyone can just point me in the right direction I would greatly appreciate it!

    my project consists of 2 files (1 midlet and 1 class):

    UnitConverter.java
    Code:
    /*
     * Description:
     * This is a Converter application, which lets a user choose from a number
     * of different conversion categories. Within each category, the user can
     * further select the type of units to convert from and to, after which the user
     * is prompted to enter a value to convert. The result is then displayed to
     * the screen.
     *
     *
     *
     */
    
    
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.rms.*;
    import java.util.Date;
    import java.io.*;
    import java.lang.*;
    
    
    public class UnitConverter extends MIDlet implements CommandListener,
    						     Runnable {
    
        private Display display = null;
        private final int MAX_CHARS = 20;
    
        //menu strings
        private static String TemperatureConverter = "Convert Temperature";
        private static String PressureConverter = "Convert Pressure";
        private static String EnergyConverter = "Convert Energy";
        private static String SpeedConverter = "Convert Speed";
        private static String DistanceConverter = "Convert Distance";
        private static String WeightConverter = "Convert Weight";
        private static String LengthConverter = "Convert Length";
    
        //submenu strings
        private static String TempCF = "C to F";
        private static String TempFC = "F to C";
        private static String convertKM = "Km to Miles";
        private static String convertMK = "Miles to Km";
        private static String convertCJ = "Calories to Joules";
        private static String convertJC = "Joules to Calories";
        private static String PressureBP = "Bars to PSI";
        private static String PressurePB = "PSI to Bars";
        private static String convertKMs = "Km to Miles";
        private static String convertMKs = "Miles to Km";
        private static String convertKP = "Kilograms to Pounds";
        private static String convertPK = "Pounds to Kilograms";
        private static String convertCI = "Cm to Inches";
        private static String convertIC= "Inches to Cm";
    
        //Declaring the menu
        List menu = null;
        Form ui_form = null;
        List menuTemp = null;
    
        Image temperature=null;
        Image pressure=null;
        Image energy=null;
        Image speed=null;
        Image distance=null;
    
    
        //Welcome message
        Alert welcome;
    
        //declaring Commands
        Command Done, Convert, Quit, Back, BackSub;
    
        //String and double variable declarations
        String str, res;
        double numUnits = 0.0;
        double result = 0.0;
    
        //declaring some objects
        Alert timeAlert;
        Image i = null;
        TextField num;
        Ticker ui_ticker = null;
    
    
    
        //constructor
        public UnitConverter()
        {
            display = Display.getDisplay(this);
            Done = new Command("Done", Command.SCREEN, 1);
            Quit = new Command("Quit", Command.SCREEN, 2);
            Convert = new Command("Convert", Command.ITEM, 1);
            Back = new Command("Back", Command.ITEM, 2);
            BackSub = new Command("Back", Command.ITEM, 2);
        }
    
        public void startApp()
        {
            //creating the first menu
            Display.getDisplay(this).setCurrent(timeAlert);
            createAlert();
            menu = new List("Term Project - Converter Application", List.IMPLICIT);
    
    	try {
                temperature = Image.createImage("images/thermometer.png");
                pressure = Image.createImage("images/pressure.png");
                energy = Image.createImage("images/energy.png");
                speed = Image.createImage("images/speed.png");
                distance = Image.createImage("images/distance.png");
            }
    	catch (IOException ioe){}
    
            //placing images on the menu
            menu.append(TemperatureConverter, temperature );
            menu.append(PressureConverter, pressure);
            menu.append(EnergyConverter, energy);
            menu.append(SpeedConverter, speed);
            menu.append(DistanceConverter, distance);
    
            // initializing the ui_ticker
            ui_ticker = new Ticker("Welcome to the Converter");
            menu.setTicker(ui_ticker);
            menu.addCommand(Quit);
    
            menu.setCommandListener(this);
            display.setCurrent(timeAlert, menu);
    
        }//End startApp()
    
    
        //creating the welcome alert
        public void createAlert() {
            try {
                i = Image.createImage("images/ampere-meter.jpg");
            }
    	catch (IOException ioe) {}
    
            // Initializing the alert with date display and no timeout
            timeAlert = new Alert("Welcome to the Converter", null, i, AlertType.INFO);
            timeAlert.setString(new Date().toString());
            timeAlert.setTimeout(timeAlert.FOREVER);
        }
    
        //creating the welcome message
        public void welcome()
        {
            display = Display.getDisplay(this);
    
            welcome = new Alert("Unit Conversion", "", null, AlertType.INFO);
            welcome.setString("Let's convert some units");
            welcome.setTimeout(Alert.FOREVER);
            welcome.addCommand(Done);
            welcome.setCommandListener(this);
            display.setCurrent(welcome);
        }//END welcome()
    
    
        public void pauseApp()
        {
        }//End pauseApp()
    
        public void destroyApp(boolean unconditional)
        {
            notifyDestroyed();
        }//End destroyApp()
    
        //processing commands from the device
        public void commandAction(Command c, Displayable d)
        {
            if ( c == Done )
                showMenu();
    
            if ( c == Quit )
                destroyApp(true);
    
            if (c == Convert)
                conversion();
    
            else if(c == Back)
                display.setCurrent(menu);
    
            else if (c == List.SELECT_COMMAND)
                run();
    
        }//End commandAction
    
    
        public void showMenu()
        {
            menu = new List("Converter", List.IMPLICIT);
    
             try {
    	     temperature = Image.createImage("images/thermometer.png");
    	     pressure = Image.createImage("images/pressure.png");
    	     energy = Image.createImage("images/energy.png");
    	     speed = Image.createImage("images/speed.png");
    	     distance = Image.createImage("images/distance.png");
    	 } catch (IOException ioe){}
    
    	 menu.append(TemperatureConverter, temperature);
    	 menu.append(SpeedConverter, pressure);
    	 menu.append(PressureConverter, energy);
    	 menu.append(EnergyConverter, speed);
    	 menu.append(DistanceConverter, distance);
    
    	 // putting the ticker in the menu
    	 menu.setTicker(ui_ticker);
    	 menu.addCommand(Quit);
    
    	 menu.setCommandListener(this);
    	 display.setCurrent(menu);
        }//END showMenu();
    
    
    
        public void run()
        {
            //processing selected converter
            int index = menu.getSelectedIndex();
            if(index == -1) return;
            String command = menu.getString(index);
    
            if (command.equals(TemperatureConverter))
    	    {
    		customForm("Convert Temperature");
    		convertSub(TemperatureConverter);
    	    }
    
            else if (command.equals(TempCF))
    	    {
    		customForm("Convert from C to F");
    		convertTemperatureCF();
    	    }
    
            else if (command.equals(TempFC))
    	    {
    		customForm("Convert from F to C");
    		convertTemperatureFC();
    	    }
    
            else if (command.equals(PressureConverter))
    	    {
    		customForm("Convert Pressure");
    		convertSub(PressureConverter);
    	    }
    
    	else if (command.equals(PressurePB))
    	    {
    		customForm("Convert from PSI to Bars");
    		convertPressurePB();
    	    }
    
    	else if (command.equals(PressureBP))
    	    {
    		customForm("Convert from Bars to PSI");
    		convertPressureBP();
    	    }
    
            else if (command.equals(EnergyConverter))
    	    {
    		customForm("Convert Energy");
    		convertSub(EnergyConverter);
    
    	    }
    	else if (command.equals(convertJC))
    	    {
    		customForm("Convert from J to Cals");
    		convertEnergyJC();
    	    }
    
    	else if (command.equals(convertCJ))
    	    {
    		customForm("Convert from Cals to J");
    		convertEnergyCJ();
    	    }
    
    	else if (command.equals(SpeedConverter))
    	    {
    		customForm("Convert Speed");
    		convertSub(SpeedConverter);
    
    	    }
            else if (command.equals(convertKMs))
                {
    		customForm("Convert from Km to Mi");
    		convertSpeedMK();
                }
    
            else if (command.equals(convertMKs))
                {
    		customForm("Convert from Mi to Km");
    		convertSpeedKM();
                }
    
    
    	     else if (command.equals(DistanceConverter))
    		 {
    		     customForm("Convert Distance");
    		     convertSub(DistanceConverter);
    
    		 }
    	     else if (command.equals(convertKM))
    		 {
    		     customForm("Convert from Km to Mi");
    		     convertDistanceKM();
    		 }
    
                 else if (command.equals(convertMK))
    		 {
    		     customForm("Convert from Mi to Km");
    		     convertDistanceMK();
                     }
    
    	     else if (command.equals(WeightConverter))
    		 {
    		     customForm("Convert Weight");
    		     convertSub(WeightConverter);
    
    		 }
    	     else if (command.equals(convertKP))
    		 {
    		     customForm("Convert from Kg to Lb");
    		     convertWeightKP();
                     }
    	     else if (command.equals(convertPK))
    		 {
    		     customForm("Convert from Lb to Kg");
    		     convertWeightPK();
                     }
    
    	     else if (command.equals(LengthConverter))
    		 {
    		     customForm("Convert Length");
    		     convertSub(LengthConverter);
    
    		 }
    	     else if (command.equals(convertCI))
    		 {
    		     customForm("Convert from Cm to In");
    		     convertLengthCI();
                     }
    
    	     else if (command.equals(convertMK))
    		 {
                      customForm("Convert from In to Cm");
                      convertLengthIC();
                     }
        }
    
    
        //create a custom convert unit entry form
        public double customForm (String fName)
        {
            ui_form = new Form(fName);
    
            ui_form.addCommand(Convert);
            ui_form.addCommand(Back);
    
            display.setCurrent(ui_form);
    
    	num = new TextField("Enter the number of units you would like to convert", "", MAX_CHARS, TextField.ANY);
            ui_form.append(num);
            ui_form.setCommandListener(this);
    
            /***********************/
            /* THIS IS NOT WORKING*/
           // str = num.getString();
            str = "The number is: " + num.getString();
            try
    	    {
    		numUnits = Double.parseDouble(str);
    	    }
            catch (NumberFormatException nfe)
    	    {
    	    }
            finally
            {
                return numUnits;
            }
    
            //return str;
        }
    
    
        public void convertSub(String s)
        {
    	menu = new List("Converter", List.IMPLICIT);
    
    	if (s.equals(TemperatureConverter))
    	    {
    		try {
    		    pressure = Image.createImage("images/pressure.png");
    		}
                    catch (IOException ioe){}
    
    		menu.append(TempCF, pressure);
    		menu.append(TempFC, pressure);
    	    }
    
    	if (s.equals(PressureConverter))
    	    {
    
                    try {
                        temperature = Image.createImage("images/thermometer.png");
                        pressure = Image.createImage("images/pressure.png");
                    }
                    catch (IOException ioe){}
    
                    menu.append(PressureBP, temperature);
                    menu.append(PressurePB, pressure);
    	    }
    
            if (s.equals(EnergyConverter))
    	    {
            	try {
    		    temperature = Image.createImage("images/distance.png");
    		    pressure = Image.createImage("images/distance.png");
    
    		} catch (IOException ioe){}
    
                    menu.append(convertCJ, temperature);
                    menu.append(convertJC, pressure);
    	    }
    
            if (s.equals(SpeedConverter))
    	    {
    		try {
                        pressure = Image.createImage("images/pressure.png");
                    }
                    catch (IOException ioe){}
    
    		menu.append(convertKMs, pressure);
    		menu.append(convertMKs, pressure);
    	    }
    
    	if (s.equals(DistanceConverter))
    	    {
    		try {
    		    temperature = Image.createImage("images/distance.png");
    		    pressure = Image.createImage("images/distance.png");
    
    		} catch (IOException ioe){}
    
    		menu.append(convertKM, temperature);
    		menu.append(convertMK, pressure);
    	    }
    
    	if (s.equals(WeightConverter))
    	    {
    		menu.append(convertKP, null);
    		menu.append(convertPK, null);
    	    }
    
            if (s.equals(LengthConverter))
    	  {
    	      menu.append(convertCI, null);
    	      menu.append(convertIC, null);
    	  }
    
            // putting the ticker in the menu
            menu.setTicker(ui_ticker);
    
            menu.addCommand(Back);
            menu.addCommand(Quit);
    
            menu.setCommandListener(this);
            display.setCurrent(menu);
    
        }
    
        /**********************************************Pressure converter *************************************** */
        public String convertPressureBP()
        {
    	PressureConverter p  = new PressureConverter("Bars", "PSI", "This is a Bar-PSI pressure converter",
    						     "TPressure converter", "Pres");
            result = p.convert(numUnits, p.getConversionConstant());
            return (res = Double.toString(result));
        }
    
    
        public String convertPressurePB()
        {
    	PressureConverter p  = new PressureConverter("PSI", "Bars", "This is a PSI-Bar pressure converter",
    						     "TPressure converter", "Pres");
            result = p.convert(numUnits, 1/(p.getConversionConstant()));
            return (res = Double.toString(result));
        }
    
    
        /**********************************************Temperature converter *************************************** */
    
        public String convertTemperatureCF()
        {
    
            TemperatureConverter c  = new TemperatureConverter("Celsius", "Fahrenheit", "This is a C-F temp converter",
    							   "Temperature converter", "Temp");
            result = c.convertCF(numUnits);
            ui_form.append("The num units in convertTemperatureCF in line 503 is: " + numUnits);
            ui_form.append("The result in convertTemperatureCF in line 504 is: " + result);
            return (res = Double.toString(result));
    
    
        }
    
    
        public String convertTemperatureFC()
        {
            TemperatureConverter c  = new TemperatureConverter("Fahrenheit", "Celsius", "This is an F-C temp converter",
    							   "Temperature converter", "Temp");
            result = c.convertFC(numUnits);
    	return (res = Double.toString(result));
    
        }
    
    
     /**********************************************Speed converter *************************************** */
    
        public String convertSpeedKM()
        {
            SpeedConverter s  = new SpeedConverter("Miles", "Kilometers", "This is a Km-Mi speed converter",
    					       "Speed converter", "Speed");
            result = s.convert(numUnits, s.getConversionConstant());
            return (res = Double.toString(result));
        }
    
    
        public String convertSpeedMK()
        {
            SpeedConverter s  = new SpeedConverter("Kilometers", "Miles", "This is a Mi-Km speed converter",
                            "Speed converter", "Speed");
            result = s.convert(numUnits, 1/(s.getConversionConstant()));
            return (res = Double.toString(result));
    
        }
    
    
        /**********************************************Distance converter *************************************** */
    
        public String convertDistanceMK()
        {
            DistanceConverter d  = new DistanceConverter("Miles", "Kilometers", "This is a Mi-Km distance converter",
    						     "Distance converter", "Dist");
            //result = d.convertKM(numUnits);
            result = d.convert(numUnits, (1/d.getConversionConstant()));
    	return (res = Double.toString(result));
        }
    
        public String convertDistanceKM()
        {
            DistanceConverter d  = new DistanceConverter("Kilometers", "Miles", "This is a Km-Mi distance converter",
    						     "Distance converter", "Dist");
            result = d.convert(numUnits, d.getConversionConstant());
    	return (res = Double.toString(result));
    
        }
    
        /**********************************************Energy converter *************************************** */
    
        public String convertEnergyJC()
        {
            EnergyConverter e  = new EnergyConverter("Joules", "Calories", "This is a Joules-Cal energy converter",
    						 "Energy converter", "En");
            result = e.convert(numUnits, 1/(e.getConversionConstant()));
            return (res = Double.toString(result));
        }
    
    
        public String convertEnergyCJ()
        {
            EnergyConverter e  = new EnergyConverter("Calories", "Joules", "This is a Cal-Joules energy converter",
    						 "Energy converter", "En");
            result = e.convert(numUnits, e.getConversionConstant());
            return (res = Double.toString(result));
        }
    
    
    /**********************************************Weight converter *************************************** */
    
        public String convertWeightKP()
        {
            WeightConverter w  = new WeightConverter("Kilograms", "Pounds", "This is a Kg-Lb weight converter",
    						 "Weight converter", "Weight");
            result = w.convert(numUnits, w.getConversionConstant());
            return (res = Double.toString(result));
        }
    
        public String convertWeightPK()
        {
            WeightConverter w  = new WeightConverter("Pounds", "Kilograms", "This is an Lb-Kg weight converter",
    						 "Weight converter", "Weight");
            result = w.convert(numUnits, 1/(w.getConversionConstant()));
            return (res = Double.toString(result));
        }
    
    /**********************************************Length converter *************************************** */
    
        public String convertLengthCI()
        {
    
            LengthConverter l  = new LengthConverter("Centimeters", "Inches", "This is a Cm-In length converter",
    						 "Length converter", "Len");
            result = l.convert(numUnits, l.getConversionConstant());
            return (res = Double.toString(result));
        }
    
        public String convertLengthIC()
        {
            LengthConverter l  = new LengthConverter("Inches", "Centimeters", "This is an In-Cm length converter",
                            "Length converter", "Len");
            result = l.convert(numUnits, 1/(l.getConversionConstant()));
            return (res = Double.toString(result));
        }
    
        //display results
        public void conversion()
        {
             ui_form.append("The value of res parameter in line 621 is: " + res);
             ui_form.append("The num units in conversion method line 622 is: " + numUnits);
            //ui_form.append(str);
        }
    }
    Last edited by sackstein; 12-06-2010 at 02:38 PM.

  • #2
    Regular Coder
    Join Date
    Jan 2009
    Posts
    160
    Thanks
    40
    Thanked 1 Time in 1 Post
    and Converter.java

    Code:
    public class Converter
    {
        private String startUnit, convertUnit, info, name, imgName;
        private double conversionConstant;
    
        public Converter (String startUnit, String convertUnit, String info, String name, String imgName)
        {
    	this.startUnit = startUnit;
    	this.convertUnit = convertUnit;
    	this.info = info;
    	this.name = name;
    	this.imgName = imgName;
        }
    
        public double convert(double numUnits, double conversionConstant)
        {
    	return (numUnits * conversionConstant);
        }
    
        public double getConversionConstant()
        {
            return conversionConstant;
        }
        
        public String getConvertUnit()
        {
    	return convertUnit;
        }
    
        public void setConvertUnit(String newConvertUnit)
        {
    	this.convertUnit = newConvertUnit;
        }
    
        public String getStartUnit()
        {
    	return startUnit;
        }
    
        public void setStartUnit(String start)
        {
    	this.startUnit = start;
        }
    
        public String getName()
        {
    	return name;
        }
    
        public void setName(String newName)
        {
    	this.name = newName;
        }
    
        public String getImgName()
        {
    	return imgName;
        }
    
        public void setImgName(String newImgName)
        {
    	imgName = newImgName;
        }
    
        public String getInfo()
        {
    	return info;
        }
    
        public void setInfo(String newInfo)
        {
    	this.info = newInfo;
    
        }
    }//end super()
    
    
    class TemperatureConverter extends Converter
    {
    
        public TemperatureConverter(String startUnit, String convertUnit, String info, String name, String imgName)
        {
    	super(startUnit, convertUnit, info, name, imgName);
        }
    
        public double convertFC(double numUnits)
        {
    	return ((5/9)*(numUnits-32));
        }
    
        public double convertCF(double numUnits)
        {
            numUnits = (9/5)*numUnits + 32;
            return numUnits;
        }
    }//end class
    
    
    class DistanceConverter extends Converter
    {
        private double conversionConstant = 0.622; //Km to Mi
    
        public DistanceConverter(String startUnit, String convertUnit, String info, String name, String imgName)
        {
    	super(startUnit, convertUnit, info, name, imgName);
        }
    }//end class
    
    
    class SpeedConverter extends Converter
    {
        private double conversionConstant = 0.622; //Km to Mi
    
        public SpeedConverter(String startUnit, String convertUnit, String info, String name, String imgName)
        {
    	super(startUnit, convertUnit, info, name, imgName);
        }
    
    }//end class
    
    class PressureConverter extends Converter
    {
        public double conversionConstant = 14.503; //Bars to PSI
    
        public PressureConverter(String startUnit, String convertUnit, String info, String name, String imgName)
        {
    	super(startUnit, convertUnit, info, name, imgName);
        }
    }//end class
    
    
    class EnergyConverter extends Converter
    {
        public double conversionConstant = 4.186; //Calories to Joules
    
        public EnergyConverter(String startUnit, String convertUnit, String info, String name, String imgName)
        {
    	super(startUnit, convertUnit, info, name, imgName);
    
        }
    }//end class
    
    class WeightConverter extends Converter
    {
        public double conversionConstant = 2.2; //Kg to Lbs
    
        public WeightConverter(String startUnit, String convertUnit, String info, String name, String imgName)
        {
    	super(startUnit, convertUnit, info, name, imgName);
    
        }
    }//end class
    
    
    class LengthConverter extends Converter
    {
        public double conversionConstant = 2.54; //Cm to In
    
        public LengthConverter(String startUnit, String convertUnit, String info, String name, String imgName)
        {
    	super(startUnit, convertUnit, info, name, imgName);
        }
    }//end class

  • #3
    Regular Coder
    Join Date
    Feb 2008
    Location
    Edinburgh - Scotland
    Posts
    107
    Thanks
    0
    Thanked 12 Times in 12 Posts
    Can you please narrow this down for us a bit! You need to just highlight the problem areas - you suspect it looks like the value they entered is always nothing - so can you paste for us the portion where the application gets the user input only? And the surrounding lines?

  • #4
    Regular Coder
    Join Date
    Jan 2009
    Posts
    160
    Thanks
    40
    Thanked 1 Time in 1 Post
    Thanks for the reply. If I had to guess where the problem was I think it is probably within the customForm method:

    Code:
      public double customForm (String fName)
        {
            ui_form = new Form(fName);
    
            ui_form.addCommand(Convert);
            ui_form.addCommand(Back);
    
            display.setCurrent(ui_form);
    
    	num = new TextField("Enter the number of units you would like to convert", "", MAX_CHARS, TextField.ANY);
            ui_form.append(num);
            ui_form.setCommandListener(this);
    
            /***********************/
            /* THIS IS NOT WORKING*/
           // str = num.getString();
            str = "The number is: " + num.getString();
            try
    	    {
    		numUnits = Double.parseDouble(str);
    	    }
            catch (NumberFormatException nfe)
    	    {
    	    }
            finally
            {
                return numUnits;
            }
    
            //return str;
        }

    I tried moving the num.getString to the commandlistener for when the convert buttons is pressed but no luck with doing that.

  • #5
    Regular Coder
    Join Date
    Feb 2008
    Location
    Edinburgh - Scotland
    Posts
    107
    Thanks
    0
    Thanked 12 Times in 12 Posts
    Right, is the TextField an SWT textfield?

    You will want to get get the contents of the field when the user clicks the button and not before - you are right about that.

    So when the user clicks the button - and if you are using SWT gui elements, you would want str = num.getText()

  • #6
    Regular Coder
    Join Date
    Jan 2009
    Posts
    160
    Thanks
    40
    Thanked 1 Time in 1 Post
    I don't know what an SWT textfield is I don't think I learned about that in class so I am going to say no?

    When I try adding str = num.getText() to the convert button in the commandListener i get an error:

    Incompatible types.
    found javax.microedition.lcdui.TextField.GetText
    required:java.lang.string

  • #7
    Regular Coder
    Join Date
    Feb 2008
    Location
    Edinburgh - Scotland
    Posts
    107
    Thanks
    0
    Thanked 12 Times in 12 Posts
    Im unsure what you are making ....and what you are making it using....

    Can you give more of a background to what you are doing - and what you are using to do it....

  • #8
    Regular Coder
    Join Date
    Jan 2009
    Posts
    160
    Thanks
    40
    Thanked 1 Time in 1 Post
    This is a program that converts from one unit to another (one of them goes from celsius to fahrenheit for example)


    That's pretty much all it needs to do. All the methods appear to be setup perfectly as far as I can tell. however the program doesnt seem to be taking the user's input (a digit) and using it. I don't believe the problem is with parsing it.

    If I hard code a number in i.e return numUnits = 5;

    then it returns a proper result

  • #9
    Regular Coder
    Join Date
    Feb 2008
    Location
    Edinburgh - Scotland
    Posts
    107
    Thanks
    0
    Thanked 12 Times in 12 Posts
    Is it a graphical application - you may need to include the entire source in order for me to understand properly whats going wrong. If it is a graphical application - what graphics library are you using?

  • #10
    Regular Coder
    Join Date
    Jan 2009
    Posts
    160
    Thanks
    40
    Thanked 1 Time in 1 Post
    it is java ME so its graphical in that sense since it's a midlet?

    There are a few graphics in the menu as well.

    here is the entire package if you want to take a look at it.

    http://bit.ly/gwLgrh

    it's really just the 2 files i pasted above though.

  • #11
    Regular Coder
    Join Date
    Feb 2008
    Location
    Edinburgh - Scotland
    Posts
    107
    Thanks
    0
    Thanked 12 Times in 12 Posts
    Right so it seems your problem is directly corrolated to Java ME I have not used it before either so perhaps you need to post on the java me forums over at oracle?

    Its definitely a problem I reckon with your interaction with the java me TextField object - so I would probably post this over at the Java ME forums :

    http://forums.oracle.com/forums/forum.jspa?forumID=990

  • Users who have thanked renegadeandy for this post:

    sackstein (12-08-2010)

  • #12
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just in case you didn't find the answer.

    The problem is because you are using two different conversionConstants variables:

    You declare the conversionConstant variable in the Converter class for doing all the conversions. This variable is initialized to default so 0.

    Then you declare another conversionConstant variable in the other classes (WeightConverter, ...) and initialize it to the value should have.

    For doing the conversion you are using the conversionConstant in Converter class which value is 0. So it's like the user entered nothing.

    hope it helps.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •