Java - visor de ficheros html con JTextPane

 
Vista:

visor de ficheros html con JTextPane

Publicado por Alberto (2 intervenciones) el 01/06/2005 18:43:18
Hola, a ver si hay alguien que me puede ayudar, por favor.
La duda es que yo quiero mostrar un fichero html (en el fichero solo hay letra, no hay ni fotos, ni dibujos, ni ninguna otra cosa) en un JTextPane y consigo que me lo muestre, pero el problema es que el estilo de la pagina viene determinado por un fichero .css, pues al mostrarlo por el JTextPane no me lo muestra en ese estilo, sino que me muestra todo el texto en negro.

El codigo que tengo hasta ahora simplificado es este:

import javax.swing.*;
import java.io.*;

public class Visor{

private static void createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
JFrame frame = new JFrame("Visor");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JEditorPane jep = new JEditorPane();
jep.setEditable(false);
jep.setContentType("text/html");
try{
FileInputStream fis = new FileInputStream("C:\\fichero.html");
jep.read(fis, null);
frame.getContentPane().add(jep);
}catch(Exception e){
System.out.println("EXCEPCION");
}
frame.getContentPane().add(jep);
frame.pack();
frame.setVisible(true);
}

public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}

Si me podeis ayudar agradeceria mucho una respuesta, porque estoy atascado y no consigo resolverlo.
Un saludo y gracias por adelantado.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder