Ciao, sto cercando di caricare immagini in un JEDitorPane, immagine che fa parte di uno script in HTML, ora l'HJTML lo carica bene invece l'immagine no, potete aiutarmi, vi posto lo script, l'immagine (logoteam.png ) si trova nella cartella "classes".
saluti Roberto
codice:import java.io.File; import java.net.MalformedURLException; import java.net.URL; import java.sql.SQLException; import javax.swing.JEditorPane; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.HTMLEditorKit; public class HtmlImmagini extends JFrame { JEditorPane editor; // costruttore public HtmlImmagini() throws MalformedURLException{ super("Prove HTMLIMMAGINI"); setSize(900, 600); setLocation(200, 200); // costruzione JEditorPane editor = new JEditorPane("text/html","<html><body"); HTMLEditorKit kit = new HTMLEditorKit(); HTMLDocument doch = new HTMLDocument(); editor.setEditorKit(kit); editor.setDocument(doch); editor.setEditable(false); // fine JEditorPane JScrollPane sc = new JScrollPane (editor); add(sc); // inizio script HTML String intestazione="<html><body><table bgcolor=red width=90% align=center ><tr>"+ "<td><img scr=\"logoteam.png\"></td>"+ "<td bgcolor=white><h1 align=center><font color=red size=9>Visualizzazione Intestazione</font></h1>" + "<hr align=center size=6 border=8 width=80%>" + "<h1 align=center><font color=red size=5 >La presente visualizzazione serve solo a verificare i dati</font></h1></td>"+ "<td><img scr=\"logoteam.png\"></td>"+ "</tr></table> "; // fine HTML // caricamento immagine File dir = new File ("classes"); URL baseUrl = dir.toURI ().toURL (); HTMLDocument htmlDoc = (HTMLDocument) editor.getDocument (); htmlDoc.setBase (baseUrl); // fine caricamenti immagine // caricamento stringa sull'editor editor.setText(intestazione); }// fine costruttore // inizio main public static void main(String [] args ){ HtmlImmagini img = new HtmlImmagini(); img.setVisible(true); } // fine main }

Rispondi quotando
puoi darmi una mano, anche in funzione del jar che seguirà, il mio script è funzionale oppure il tuo di cui parlavi è più pratico.