Pregunta

Tengo un pequeño problema con un widget SWT.Browser que arroja una alerta bastante desconcertante.

Intenté probar la API de Google StreetView en un navegador, así que creé esta página (en realidad no hice nada, solo la pegué del fragmento de Google) y recibo el siguiente mensaje:alt text

(Desconcertante, ¿no?)

Mi código es muy simple (aquí está)

public static void main(String[] args) {
    Display display = Display.getDefault();
    Shell shell = new Shell(display);
    shell.setText("Tentative API Google avec un SWT.Browser");
    shell.setLayout(new GridLayout());
    final Browser browser = new Browser(shell,SWT.BORDER);
    browser.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
    browser.setText("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"+
                    "<html xmlns=\"http://www.w3.org/1999/xhtml\" mlns:v=\"urn:schemas-microsoft-com:vml\">"+
                      "<head>"+
                        "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\"/>"+
                        "<script src=\"http://maps.google.com/maps?file=api&v=2.x&key=AnyKey\" type=\"text/javascript\"></script>" +
                        "<title>"+
                          "Google Maps JavaScript API Example: Simple Streetview Example"+
                        "</title>" +
                        "<script type=\"text/javascript\">var myPano;function initialize(){var fenwayPark = new GLatLng(42.345573,-71.098326);panoramaOptions = { latlng:fenwayPark };myPano = new GStreetviewPanorama(document.getElementById(\"pano\"), panoramaOptions);GEvent.addListener(myPano, \"error\", handleNoFlash);}function handleNoFlash(errorCode){if(errorCode == FLASH_UNAVAILABLE){alert(\"Error: Flash doesn't appear to be supported by your browser\");return;}}</script>" +
                      "</head>" +
                      "<body onload=\"initialize()\" onunload=\"GUnload()\">" +
                        "<div name=\"pano\" id=\"pano\" style=\"width: 500px; height: 300px\">" +
                        "</div>" +
                      "</body>" +
                    "</html>");
    shell.open();

    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}

El problema puede venir (más o menos) de la API porque cuando no la incluyo no me sale ningún error.De todos modos, esta misma página funciona perfectamente en cualquier navegador estándar.Aún más sorprendente es que no recibo ningún error si mi segundo Guion la etiqueta no está cerrada (bueno, entonces no pasa nada y si vamos por este camino, cuando no tengo absolutamente ningún código no tengo ningún error...)

Aquí estoy ...Un poco confundido sobre qué hacer...(Cualquier ayuda es bienvenida ...)

¿Fue útil?

Solución

Este problema desapareció cuando surgió cuando desplacé todo mi código HTML en un archivo llamado por

browser.setUrl("http://my.url-string.html");

Entonces, de hecho, no puedo resolver el problema, pero ya no me molesta ...

ps: el método para obtener la URL de mi página local (que he puesto en el mismo directorio que mi archivo java) es Class.getRessource (" Mi ruta de archivo a la que puedo agregar su ruta en la ruta de clase ")

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top