Hello,
I am trying to add a Browser Field onto my Main Screen. Currently, I have:
public class BrowserFieldDemo extends UiApplication {
private MainScreen _browserScreen;
private BrowserField _bf2;
private BrowserFieldConfig _bfConfig;
public BrowserFieldDemo(final String url) {
_browserScreen = new MainScreen();
_bfConfig = new BrowserFieldConfig();
_bfConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,
BrowserFieldConfig.NAVIGATION_MODE_POINTER);
_bfConfig.setProperty(BrowserFieldConfig.JAVASCRIPT_ENABLED,
Boolean.TRUE);
_bf2 = new BrowserField(_bfConfig);
_browserScreen.add(_bf2);
invokeLater(new Runnable() {
public void run() {
_bf2.requestContent(url);
pushScreen(_browserScreen);
}
});
}
}
What is the correct way to insert the browser to into Main Screen class, amongst other UI elements? For example, add(myBrowserField)? I am unsure how to set up the BrowserFieldDemo class to do this, because I need to extend UIApplication for the Thread...
public class LoginScreen extends MainScreen implements FieldChangeListener{}
Thanks!
Update:
I now have the following:
public class LoginBrowserField extends Thread {
private LoginScreen loginScreen;
private String url;
public LoginBrowserField(String url, LoginScreen loginScreen) {
this.loginScreen = loginScreen;
this.url = url;
}
public void run() {
synchronized (UiApplication.getEventLock()) {
loginScreen.changeURL(url);
}
}
}
public class LoginScreen extends MainScreen implements FieldChangeListener {
public void changeURL(final String url) {
_bf2.requestContent(url);
_bf2.setFocus();
}
}
And to start the browser, I call (in LoginScreen):
LoginBrowserField browser = new LoginBrowserField(url, this);
browser.start();
However, I am not sure if my setup above is correct because it is taking a really long time for the browser to appear in the application, and it does not correctly resolve my URL. Can you see anything that is wrong?
Thanks!