JEditorPane setPage() 问题?? 急~

angel8808 2010-05-21 01:17:45
jEditorPane1.setPage("file:///" + filePath + fileName)
打开一个html文件,显示正常,然后继续写入html,然后再调用上面那句,jEditorPane1就一直保持第一次显示的内容了
不管html内容怎么变。我用浏览器打开,html确实已经变了,我又写了一个类测试,用JEditorPan打开也显示正常,说明html本身没有什么问题。我要实现jEditorPane1随着本地html文件的变化一起变,怎么实现???
...全文
136 4 打赏 收藏 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
huntor 2010-05-22
  • 打赏
  • 举报
回复
File 类有 public long lastModified(); 方法。
使用定时器每隔几秒检测一次,发生变化后,重新调用setPage
zihuzihuzihu 2010-05-21
  • 打赏
  • 举报
回复
zihuzihuzihu 2010-05-21
  • 打赏
  • 举报
回复
focusforce 2010-05-21
  • 打赏
  • 举报
回复
别那么构造URL对象
这么写呢:
File f = new File(filePath + File.Seperator + fileName);
URL url = null;
try
{
url = f.toURI().toURL();
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
jEditorPane1.setPage(url);

62,620

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧