1
我需要使用指向Google靜態圖的URL從我的Java Swing應用程序打開瀏覽器。從Java Swing應用程序打開Google靜態圖
我用的是1.6的桌面類打開瀏覽器,但我收到以下錯誤:
Internet Explorer cannot download staticmap from mpas.google.com. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
然而,當我打開Internet Explorer並粘貼URL,它工作正常。
爲什麼Internet Explorer不能正常工作?這是網址:
下面是代碼snipplet,我打開網址:
Desktop desktop = Desktop.getDesktop();
if (!desktop.isSupported(Desktop.Action.BROWSE)) {
System.out.println("Desktop does not support browse mode.");
} else {
try {
URI uri = new URI("http://maps.google.com/maps/api/staticmap?zoom=6&size=400x400&markers=color:green%7Clabel:1%7C40.837375,-85.646872&sensor=false");
desktop.browse(uri);
} catch (IOException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
也許張貼代碼片段,您嘗試打開URL ... – MatrixFrog 2011-05-31 04:05:43