如何在JFrame
内显示多个网页?
JEditorPane website = new JEditorPane(line);
website.setEditable(false);
JFrame frame = new JFrame("JxBrowser");
addressBar.setText(line);
frame.add(new JScrollPane(website));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(800, 600);
frame.setVisible(true);
我已将此代码放在for
循环中,因为通常的网站在不同的框架中打开,我希望我的所有浏览器网站都在一个框架内打开,
这怎么可能?
答案 0 :(得分:0)
正如@JBNizet在评论中提到的,你可以使用JTabbedPane。
不要将网站JEditorPane直接添加到JFrame,而是执行此操作:
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.add("Website Title", new JScrollPane(website));
frame.add(tabbedPane);
当然,您不应该为每个网站创建新的JTabbedPane或新的JFrame,而只需将网站作为新标签添加到现有的选项卡式窗格中。
不要忘记每个标签都需要自己的addressBar对象。