我想在java swing应用程序中显示一个网页.类似于使用HTML时,但在Java Swing中.这是可能的,如果是的话,怎么样?
eli*_*ias 22
使用JEditorPane:
JEditorPane jep = new JEditorPane();
jep.setEditable(false);
try {
jep.setPage("http://www.yoursite.com");
}catch (IOException e) {
jep.setContentType("text/html");
jep.setText("<html>Could not load</html>");
}
JScrollPane scrollPane = new JScrollPane(jep);
JFrame f = new JFrame("Test HTML");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(scrollPane);
f.setPreferredSize(new Dimension(800,600));
f.setVisible(true);
Run Code Online (Sandbox Code Playgroud)
您可能需要查看http://java.dzone.com/articles/web-browser-your-java-swing.
JxBrowser允许您通过将浏览器嵌入到swing应用程序中来显示任何网页.
| 归档时间: |
|
| 查看次数: |
32945 次 |
| 最近记录: |