private void startNavegador(final Form f) {
Form f = Display.getInstance().getCurrent();
String textoUrl = TextoUrl.getText();
if (findContainerBrowser(f).getComponentCount() == 0) {
Navegador = new BrowserComponent();
Navegador.addWebEventListener("onError", new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if ( detectaInternet()) {
String textoUrl = TextoUrl.getText();
textoUrl = "https://" + textoUrl;
Navegador.setURL(textoUrl);
}
}
});
Navegador.addWebEventListener("onLoad", new ActionListener() {
public void actionPerformed(ActionEvent evt) {
TextoUrl.setText(Navegador.getURL());
}
});
if ( ! textoUrl.startsWith("http") ) {
textoUrl = "http://" + textoUrl;
}
findContainerBrowser(f).addComponent(BorderLayout.CENTER, Navegador);
findContainerBrowser(f).revalidate();
}
if ( ! textoUrl.equals("http://") )
Navegador.setURL(textoUrl);
}
(…..........)
@Override
protected void onRecetas_Button6Action(Component c, ActionEvent event) {
Form f = c.getComponentForm();
accionNavegador(TextoUrl);
}
private void accionNavegador(TextField TextoUrl) {
String textoUrl = TextoUrl.getText();
if ( ! textoUrl.startsWith("www") && ! textoUrl.startsWith("http") ) {
textoUrl = "www." + textoUrl;
}
if ( ! textoUrl.startsWith("http") ) {
textoUrl = "http://" + textoUrl;
}
Navegador.setURL(textoUrl);
}