1
votes

Testing a new project with CodenameOne with Netbeans, BrowserComponent produces NullPointerException just by Initializing, but not in the main thread!

public void start() {
    if(helpForm != null){
        helpForm.show();
    //    return;
    }
         BrowserComponent browser=new  BrowserComponent();

    
}

getting this error:

java.lang.NullPointerException
[EDT] 0:0:0,873 - Exception: java.lang.NullPointerException - null
    at com.codename1.ui.Container.insertComponentAtImpl(Container.java:926)
    at com.codename1.ui.Container.insertComponentAt(Container.java:918)
    at com.codename1.ui.Container.addComponent(Container.java:855)
    at com.codename1.ui.BrowserComponent$9.run(BrowserComponent.java:534)
    at com.codename1.ui.Display.processSerialCalls(Display.java:1331)
    at com.codename1.ui.Display.edtLoopImpl(Display.java:1274)
    at com.codename1.ui.Display.mainEDTLoop(Display.java:1162)
    at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
    at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)

1

1 Answers

1
votes

To use the BrowserComponent on the simulator, you'll need to either be using a JDK that includes JavaFX (e.g. ZuluFX), or you'll need to have the CEF library installed.

See https://www.codenameone.com/blog/big-changes-jcef.html for details about this.

This doesn't affect device builds - just the simulator. We're in a transition phase right now - phasing out JavaFX and phasing in CEF for media and browser component - at some point we'll just make CEF automatic and seamless. But for now, you just need to install it manually or use a JavaFX JDK.