2015-10-19 34 views
3

我試圖安裝JxBrowser(以下this tutorial),並安裝JxBrowser驅動程序後:JxBrowser BrowserFactory從驅動程序文件丟失

enter image description here

我試圖編譯,並注意到了必要的進口​​失蹤:

enter image description here

而且,通過驅動程序中的類文件翻找,果然沒有​​可用:

enter image description here

我做錯什麼了嗎? JxBrowser是否有必要的組件?新版本的驅動程序是否不包含​​類?

回答

5

https://dzone.com/articles/google-maps-java-swing上的示例基於JxBrowser 4.x API。您使用的JxBrowser 5.x API有點不同。現在,使用5.x API創建Browser實例時,不需要使用​​類。

下面的示例演示如何編寫與JxBrowser 5.x的API相同的代碼:

import com.teamdev.jxbrowser.chromium.Browser; 
import com.teamdev.jxbrowser.chromium.swing.BrowserView; 

import javax.swing.*; 
import java.awt.*; 

/** 
* This sample demonstrates how to load a web page with Google Maps 
* and control it using JxBrowser API. 
*/ 
public class GoogleMapsSample { 
    public static void main(String[] args) { 
     Browser browser = new Browser(); 
     BrowserView view = new BrowserView(browser); 

     JFrame frame = new JFrame("JxBrowser Google Maps"); 
     frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 
     frame.add(view, BorderLayout.CENTER); 
     frame.setSize(700, 500); 
     frame.setLocationRelativeTo(null); 
     frame.setVisible(true); 

     browser.loadURL("http://maps.google.com"); 
    } 
} 
+0

優秀的解釋。謝謝! –

相關問題