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
Contributor
Posts: 10
Registered: ‎02-11-2013
My Device: 9900
My Carrier: airtel

Java.lang.ClassCastException error in simulator

I am trying to run my blackberry application on my simulator, but getting exception classcast exception each time the application runs.
My code is :
AppName() {
try {
BrowserFieldRequest request = new BrowserFieldRequest("url");
_browserScreen = new BrowserFieldScreen(request, true);
pushScreen(_browserScreen);
}
catch(Exception e)
{
errorDialog("An error occurred, exiting AppName: " + e.toString(), true);
}
}

and in my BrowserFieldScreen.java:

public BrowserFieldScreen(BrowserFieldRequest request, boolean enableScriptMenu) {
super(Screen.HORIZONTAL_SCROLL);

    BrowserFieldConfig config = new BrowserFieldConfig();  
   // config.setProperty(BrowserFieldConfig.ALLOW_CS_XHR, Boolean.TRUE);     
    config.setProperty(BrowserFieldConfig.NAVIGATION_MODE , BrowserFieldConfig.NAVIGATION_MODE_POINTER );     
    config.setProperty(BrowserFieldConfig.USER_SCALABLE , Boolean.FALSE);     
    config.setProperty(BrowserFieldConfig.VIEWPORT_WIDTH , new Integer(Display.getWidth()));
  //  config.setProperty(BrowserFieldConfig.INITIAL_SCALE, new Float(0.5));
    config.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED,Boolean.TRUE);


    _browserField = new BrowserField(config);
    _browserField.addListener(new DemoBrowserListener());
    _browserField.setZoomScale((float) 0.5); 
    GIFEncodedImage bitmapImage=(GIFEncodedImage)GIFEncodedImage.getEncodedImageResource("loading.gif");
  //     hfm = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);
 //   image_field=new AnimatedGIFField(bitmapImage,DrawStyle.HCENTER|DrawStyle.VCENTER);
//    hfm.add(image_field);
//    add(hfm);
    add(_browserField);


    _request = request;    

}

Please help. How to get rid of this error..

Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Java.lang.ClassCastException error in simulator

i would suggest to use debug mode to check where the exception occurs and what its detail message says.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 10
Registered: ‎02-11-2013
My Device: 9900
My Carrier: airtel

Re: Java.lang.ClassCastException error in simulator

There is no error found in console. Now what to do??

Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Java.lang.ClassCastException error in simulator

set an exception breakpoint in eclipse (on classcast exception)
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Contributor
Posts: 10
Registered: ‎02-11-2013
My Device: 9900
My Carrier: airtel

Re: Java.lang.ClassCastException error in simulator

How to apply in my try catch as shown above.

please help.

Developer
Posts: 16,987
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Java.lang.ClassCastException error in simulator

in eclipse: run, add java exception breakpoint, select exception, click ok
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter