This Browser instance, embed it into Swing BrowserView container, display it in JFrame and navigate to the "www.google.com" website. example demonstrates how to create (此示例演示如何创建Browser实例,将其嵌入到Swing BrowserView容器中,在JFrame中显示它以及导航到“ www.google.com”网站。)
import com.teamdev.jxbrowser.chromium.Browser; import com.teamdev.jxbrowser.chromium.swing.BrowserView; import javax.swing.*; import java.awt.*; /** * This example demonstrates how to create Browser instance, * embed it into Swing BrowserView container, display it in JFrame and * navigate to the "www.google.com" web site. */ public class BrowserSample { public static void main(String[] args) { Browser browser = new Browser(); BrowserView view = new BrowserView(browser); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(view, BorderLayout.CENTER); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.add(panel, BorderLayout.CENTER); frame.setSize(700, 500); frame.setLocationRelativeTo(null); frame.setVisible(true); browser.loadURL("http://google.com"); } }