Il seguente codice:
codice:
String html = "<html>\r\n" +
"<body background=\"bg.gif\">\r\n" +
"\r\n" +
" ....... " +
"\r\n" +
"</body>\r\n" +
"</html>";
editorPane = new JEditorPane ();
editorPane.setContentType ("text/html");
File dir = new File ("test");
URL baseUrl = dir.toURI ().toURL ();
HTMLDocument htmlDoc = (HTMLDocument) editorPane.getDocument ();
htmlDoc.setBase (baseUrl);
editorPane.setText (html);
fa caricare correttamente la immagine bg.gif ammesso che si trovi nella directory "test" relativa alla current working directory.
Come vedi, basta impostare correttamente la "base URL" affinché una immagine specificata in modo relativo possa essere caricata.