I am an email client. I want to be able to send the emails in rich-text format, so the GUI uses a JTextPane as the Text Component in which the user's message is entered. The problem is that when I call textPane.getTex t() the returned string contains only HTML tags, no actual text. So my question is how do I get the HTML content from a JTextPane, including tags and text, to use in a JavaMail application? Here is the jist of what I have tried:
Having entered some arbitrarily formatted text and calling System.out.prin tln(message) the following output is produced. (The output of course varies with the random non-sense I enter into the JTextPane whilst testing, but it is always only tags)
Code:
//a lot of GUI code JTextPane textPane = new JTextPane(); textPane.setEditorKit( new HTMLEditorKit() ); textPane.setDocument( new HTMLDocument() ); //more GUI code String message = textPane.getText(); //then code to send the email
Code:
<html>
<head>
</head>
<body>
<p style="margin-top: 0">
<font face="Dialog" size="3"><Dialog>
<u><Dialog>
</u><b><Dialog>
</b></font><b><font face="Dialog" size="7"><Dialog>
</font></b> </p>
</body>
</html>
Comment