[問題] JeditorPane顯示html

看板java作者 (療傷中)時間11年前 (2014/05/28 17:33), 11年前編輯推噓1(102)
留言3則, 2人參與, 最新討論串1/1
如題我想把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://www.ptt.cc/bbs/java/M.1401269618.A.0C5.html

05/28 18:08, , 1F
不要自己生... 生個File 然後.toURI().toURL()
05/28 18:08, 1F
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

05/28 18:58, , 2F
你要不要先確認一下 Fhtml.getAbsolutePath()
05/28 18:58, 2F

05/28 18:58, , 3F
另外,完全沒有錯誤訊息也十分詭異,難道是版規 5 作祟?
05/28 18:58, 3F
文章代碼(AID): #1JXQro35 (java)
文章代碼(AID): #1JXQro35 (java)