import java.io.IOException;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.WindowConstants;
/**
* 使用JEditorPane 显示WEB页面
* @author Vic
*
*/
public class OreillyHomePage {
public static void main(String[] args) {
JEditorPane jep = new JEditorPane();
jep.setEditable(false);
try {
jep.setPage("http://www.oreilly.com");
} catch (IOException e) {
jep.setContentType("text/html");
jep.setText("<html>Could not load http://www.oreilly.com </html>");
}
JScrollPane scrollpane = new JScrollPane(jep);
JFrame f = new JFrame("'0'Reilly & Associates");
f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
f.setContentPane(scrollpane);
f.setSize(512,342);
f.show();
}
}
使用JEditorPane 显示WEB页面
最新推荐文章于 2021-02-26 15:50:36 发布
本文介绍了一个简单的Java程序,该程序使用Swing组件JEditorPane来加载并显示指定的网页内容。通过设置JEditorPane的Page属性为所需的URL,可以实现网页的加载。若加载失败,则会显示错误信息。
4218

被折叠的 条评论
为什么被折叠?



