Java - JTextPane con superíndices y subíndices

 
Vista:

JTextPane con superíndices y subíndices

Publicado por Roberto (2 intervenciones) el 14/03/2007 16:28:29
Necesito saber como puedo hacer para que éste componente me reconozca los subíndices u superíndices al cargar un archivo rtf, es decir, cuando hago:

JEditorPane epTexto = new JEditorPane();
RTFEditorKit rtf = new RTFEditorKit();
epTexto.setEditorKit(rtf);
FileInputStream fis = new FileInputStream("UnArchivo.rtf");
rtf.read(fis, epTexto.getDocument(), 0);

Me trae todo el texto al panel pero pierde los superíndices y los subíndices.

¿Hay alguna forma de hacerlo bien?

Gracias, por su ayuda.
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

RE:JTextPane con superíndices y subíndices

Publicado por Roberto maccari (2 intervenciones) el 14/03/2007 20:01:16
Bueno, ya se cual es el problema.
La clase javax.swing.text.rtf.RTFAttributes tiene la siguiente secuencia de código en donde se determinan los atributos de texto leído.

a.addElement(new BooleanAttribute(CHR, StyleConstants.Italic, "i"));
a.addElement(new BooleanAttribute(CHR, StyleConstants.Bold, "b"));
a.addElement(new BooleanAttribute(CHR, StyleConstants.Underline, "ul"));

¡¡¡ACA FALTA DEFINIR ESTO!!!
a.addElement(new BooleanAttribute(CHR, StyleConstants.Superscript, "super"));
a.addElement(new BooleanAttribute(CHR, StyleConstants.Subscript, "sub"));

Ahora otra pregunta:

Donde tengo que envíar esto para que corrijan el error.

Muchas gracias por su mostia
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar