不可能将jxbrowser内容添加到jpanel中。当我将jxBrowser内容添加到JFrame中时,很容易看到它。但我无法将jxBrowser内容添加到jpanel中。我不知道这是否不可能,或者我无法将jxBrowser内容添加到jpanel中。
发布于 2014-09-15 11:09:06
下面的示例代码演示如何将JxBrowser浏览器组件嵌入到JPanel中:
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
import javax.swing.*;
import java.awt.*;
/**
* This sample 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(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("https://google.com");
}
}在https://jxbrowser.support.teamdev.com/support/solutions/9000049010可以找到更多的样本
发布于 2017-05-31 12:51:13
实际上,jxbrowser能够添加到Jpanel中。我也遇到过同样的问题。这仅仅是因为我在初始化BorderLayout时没有指定JPanel。密码没问题。
JPanel panel = new JPanel(new BorderLayout());https://stackoverflow.com/questions/24850304
复制相似问题