1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.BrowserType;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
import javax.swing.*;
import java.awt.*;
/**
* The sample demonstrates how to use Browser in JInternalFrame components.
*/
public class JInternalFrameSample {
public static void main(String[] args) {
JDesktopPane desktopPane = new JDesktopPane();
desktopPane.add(createInternalFrame("Browser One", "http://www.teamdev.com", 0));
desktopPane.add(createInternalFrame("Browser Two", "http://www.google.com", 100));
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.add(desktopPane, BorderLayout.CENTER);
frame.setSize(800, 800);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
private static JInternalFrame createInternalFrame(String title, String url, int offset) {
Browser browser = new Browser(BrowserType.LIGHTWEIGHT);
BrowserView view = new BrowserView(browser);
browser.loadURL(url);
JInternalFrame internalFrame = new JInternalFrame(title, true);
internalFrame.setContentPane(view);
internalFrame.setLocation(100 + offset, 100 + offset);
internalFrame.setSize(400, 400);
internalFrame.setVisible(true);
return internalFrame;
}
} |
Partager