-
Bug
-
Resolution: Unresolved
-
P3
-
None
-
6u3
-
x86
-
windows_xp
The method JTextPane.getText() returns invalid HTML. The follow test program show the original HTML
that was set with setText() and the resulting HTML from the method getText(). The original HTML
display correct with a size of 11px. The resulting HTML will show from browser and from Java with
a font size of 36pt.
If it is not a FONT tag else a DIV tag then all infos are lost. We want use JTextPane as editor
in a mail client. It is fatal if it show not correct and if it save/send it look completly other.
The problem occur with Java 5 and Java 6. Currently we does not know a workaround.
Test program:
import javax.swing.JTextPane;
public class TestGetHtml {
public static void main( String[] args ) {
JTextPane text = new JTextPane();
text.setContentType( "text/html" );
String originalHtml = "<font face='Arial' style='font-size:11px'>any text</font>";
text.setText( originalHtml );
System.out.println(originalHtml);
System.out.println("===========");
System.out.println(text.getText());
}
}
Output with FONT tag:
<font face='Arial' style='font-size:11px'>any text</font>
===========
<html>
<head>
</head>
<body>
<font face="Arial" size="11px">any text</font>
</body>
</html>
Output with DIV tag:
<div style='font-name:Arial;font-size:11px'>any text</div>
===========
<html>
<head>
</head>
<body>
<div>
any text
</div>
</body>
</html>
that was set with setText() and the resulting HTML from the method getText(). The original HTML
display correct with a size of 11px. The resulting HTML will show from browser and from Java with
a font size of 36pt.
If it is not a FONT tag else a DIV tag then all infos are lost. We want use JTextPane as editor
in a mail client. It is fatal if it show not correct and if it save/send it look completly other.
The problem occur with Java 5 and Java 6. Currently we does not know a workaround.
Test program:
import javax.swing.JTextPane;
public class TestGetHtml {
public static void main( String[] args ) {
JTextPane text = new JTextPane();
text.setContentType( "text/html" );
String originalHtml = "<font face='Arial' style='font-size:11px'>any text</font>";
text.setText( originalHtml );
System.out.println(originalHtml);
System.out.println("===========");
System.out.println(text.getText());
}
}
Output with FONT tag:
<font face='Arial' style='font-size:11px'>any text</font>
===========
<html>
<head>
</head>
<body>
<font face="Arial" size="11px">any text</font>
</body>
</html>
Output with DIV tag:
<div style='font-name:Arial;font-size:11px'>any text</div>
===========
<html>
<head>
</head>
<body>
<div>
any text
</div>
</body>
</html>