Java swing控件和JxBrowser页面同框?

Java swing controls and JxBrowser page in the same frame?

我好像找不到这方面的任何信息,是否可以使用 JxBrowser 显示网页和 java 在同一框架内摆动控件,如果可以,怎么做?我当前的代码只是一个显示 window 和 google 地图的代码,因为我一直在尝试并删除它们。

public static void main(String[] args) {
    Browser browser = new Browser();
    BrowserView view = new BrowserView(browser);
    JFrame frame = new JFrame("Google Maps");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.add(view, BorderLayout.CENTER);
        frame.setSize(1500,1000);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
        browser.loadURL("http://maps.google.com");
}

嵌入到框架中的 BrowserView 是一个 Swing 组件。您可以用同样的方法添加其他Swing组件:

public static void main(String[] args) {
    Browser browser = new Browser();
    BrowserView view = new BrowserView(browser);

    JFrame frame = new JFrame("Google Maps");
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    frame.add(view, BorderLayout.CENTER);

    // Let's add a button
    frame.add(new JButton("My Button"), BorderLayout.SOUTH);

    frame.setSize(1500,1000);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

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