作者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/m.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