读书人

JEditorPane 展示网页 解析html代码

发布时间: 2012-09-22 21:54:54 作者: rapoo

JEditorPane 显示网页 解析html代码

方法一
这是比较基本的方法

?
[编辑]方法二
方法一最大的缺点在于说,如果你有一狗票的内容HTML,要这么傻傻地用的setText()的方式去输入吗?当然有别的方法,首先我们另外写一个HTML档,暂且称之为 JEditPane XD = new JEditPane(); XD.setContentType( "text/html "); HTMLEditorKit kit = new HTMLEditorKit(); XD.setEditorKit(kit); HTMLDocument doc = (HTMLDocument)XD.getDocument(); File f = new File( "sample.html "); try { FileInputStream reader = new FileInputStream(f); kit.read(reader,doc,0); }catch(Exception e) { e.printStackTrace(); }
?

读书人网 >CSS

热点推荐