Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Trusted Contributor
Posts: 138
Registered: ‎04-19-2012
My Device: No
My Carrier: Nokia

Re: I am not setting any value in my constructor. i am doing...

i am setting 

textbox.settext(formattervalue);................this line coz error.

i am getting uncought exp.

Highlighted
Trusted Contributor
Posts: 138
Registered: ‎04-19-2012
My Device: No
My Carrier: Nokia

Re: I am not setting any value in my constructor. i am doing...

[ Edited ]

i am posting my complete code.what i want after given the value in textfield it should roundoff and show like this exp. 6567643433.0

 

//for round off
public static Float getFloatValue(String value, int decimalPlaces)
    {
        Float retVal = null;
        
        try
        {
            float floatValue = Float.parseFloat(value);
            floatValue = roundOffDecimals(floatValue, decimalPlaces);
            retVal = new Float(floatValue);
        }
        catch(NumberFormatException nfe) 
        {
            //do nothing
        }
        
        return retVal;
    }

//format

 protected void formatAnswer()
    {
        Float floatValue = Myclass.getFloatValue(textBox.getText(), numericDetails.getDecimalPlaces());
        
        if (floatValue != null)
        {
            String formattedText = String.valueOf(floatValue);
           
            //set the rounded off value to the text box
            textBox.setText(formattedText);            
        }
    }

 

problem is after 7 digit .it crashed.