作者forget2009 (疗伤中)
看板java
标题[问题] JeditorPane显示html
时间Wed May 28 17:33:32 2014
如题我想把html呈现在JEditorPane上面,html存在java专案的目录当中为map.html
但我尝试了很多次,结果都是没有显示任何东西
但把url改为google网址则可以显示结果。
以下是我的code,可以告诉我哪个部分出错了吗@@
sPath = System.getProperty( "user.dir" ) + "/";
URL url=new URL("File:///"+sPath+"map.html");
editorPane = new JEditorPane();
scrollPane.setViewportView(editorPane);
editorPane.setContentType("text/html");
editorPane.setEditable(false);
editorPane.setPage(url);
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 140.113.153.80
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/java/M.1401269618.A.0C5.html
1F:→ danny8376:不要自己生... 生个File 然後.toURI().toURL() 05/28 18:08
File Fhtml=new File("map.html");
URL url=Fhtml.toURI().toURL();
editorPane = new JEditorPane();
scrollPane.setViewportView(editorPane);
editorPane.setContentType("text/html");
editorPane.setEditable(false);
editorPane.setPage(url);
我改成这样了还是无法QQ...
※ 编辑: forget2009 (140.113.153.80), 05/28/2014 18:14:23
2F:推 PsMonkey:你要不要先确认一下 Fhtml.getAbsolutePath() 05/28 18:58
3F:→ PsMonkey:另外,完全没有错误讯息也十分诡异,难道是版规 5 作祟? 05/28 18:58