2015-10-19 42 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

优秀的解释。谢谢! –