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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Visitor
tujasiri
Posts: 1
Registered: ‎06-14-2012
My Carrier: 5043107628

Browserfield Example not launching

Greetings All,

 

I'm attempting to run a very simple Blackberry/Java application which implements the BrowserField class. When I launch it in the simulator it just hangs. When I launch it on my device nothing happens.

JRE: 7.0
Simulator: 4.0.0.141

 

 

package mypackage;

import net.rim.device.api.browser.field2.BrowserField;
import net.rim.device.api.browser.field2.BrowserFieldConfig;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.container.MainScreen;

public class BrowserJazz extends UiApplication
{
public static void main(String[] args)
{
BrowserJazz app = new BrowserJazz();
app.enterEventDispatcher();
}

public void BrowserJazz()
{
pushScreen(new BrowserFieldDemoScreen());
}
}

class BrowserFieldDemoScreen extends MainScreen
{
public BrowserFieldDemoScreen()
{
BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();

 


myBrowserFieldConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,
BrowserFieldConfig.NAVIGATION_MODE_POINTER);

BrowserField browserField = new BrowserField(myBrowserFieldConfig);

/*BrowserFieldListener listener = new BrowserFieldListener() {
public void documentLoaded(BrowserField browserField) throws Exception
{
// the document has loaded, do something ...
Dialog.inform("PAGE LOADED!");
}
};*/

add(browserField);
//browserField.addListener( listener );

browserField.requestContent("http://www.google.com");
//browserField.addListener( listener );

}
}

 

Any ideas?

-TU

Please use plain text.
Developer
crispyoz
Posts: 223
Registered: ‎10-01-2011

Re: Browserfield Example not launching

Try this in your screen:

 

public final class TestScreen extends MainScreen
{

     BrowserField browserField;
     

    public TestScreen()

    {
        BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();

        myBrowserFieldConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,
        BrowserFieldConfig.NAVIGATION_MODE_POINTER);
        browserField = new BrowserField(myBrowserFieldConfig);
        add(browserField);

        addMenuItem(goMenu);
    }

 

    private MenuItem goMenu = new MenuItem("Go", 0x240000, 0){
         public void run(){
               browserField.requestContent("http://www.google.com");
         }
    };
}

 

Push this screen then select Go form the menu. I found that setting the content of the brower field in the construction will cause issues, I suspect because the field may not be fully instantiated when you are attempting to populate it.

 

 

Please use plain text.