jwebbrowser要什么包_DJ Native Swing JWebBrowser面板无法在JTabbedPane内部工作

姬和豫
2023-12-01

我意识到这个答案有点迟到,但这就是我做到的

这是扩展JPanel并定义浏览器的类:

public class BrowserPanel extends JPanel {

public BrowserPanel() {

super(new BorderLayout());

JPanel webBrowserPanel = new JPanel(new BorderLayout());

webBrowserPanel.setBorder(BorderFactory.createTitledBorder(""));

final JWebBrowser webBrowser = new JWebBrowser();

webBrowser.navigate("bigfarm.goodgamestudios.com/?country=RO");

webBrowserPanel.add(webBrowser, BorderLayout.CENTER);

add(webBrowserPanel, BorderLayout.CENTER);

}}

然后我创建了一个扩展JFrame并保存JTabbedPane的类

public class WhateverFrame extends JFrame{

private JTabbedPane tabbedPane;

public WhateverFrame() {

BrowserPanel x=new BrowserPanel();

tabbedPane = new JTabbedPane(JTabbedPane.TOP);

tabbedPane.add(x, BorderLayout.WEST);

tabbedPane.setTitleAt(0, "Start");

/*

* add the tabbedPane to the content pane

*/

setContentPane(tabbedPane);

}主要看起来像这样:

public static void main(String[]args){

UIUtils.setPreferredLookAndFeel();

NativeInterface.open();

SwingUtilities.invokeLater(new Runnable() {

public void run() {

WhateverFrame frame=new WhateverFrame();

frame.setExtendedState(Frame.MAXIMIZED_BOTH);

frame.setLocation(0,0);

frame.setVisible(true);

}

});

}

 类似资料: