How can I display more than one webpage inside a 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);
I have put this code inside a for
loop, as usual website are open in different frame, I want all my browser websites to be open inside a single frame,
How this is possible?
As @JBNizet mentioned in the comments, you could use a JTabbedPane.
Instead of adding the website JEditorPane directly to the JFrame, do this:
JTabbedPane tabbedPane = new JTabbedPane();
tabbedPane.add("Website Title", new JScrollPane(website));
frame.add(tabbedPane);
Of course, you shouldn't create a new JTabbedPane or new JFrame for each website, instead you should just add the website as a new tab to the already existing tabbed pane.
Don't forget that each tab would require their own addressBar object.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.