Yes, Dirk. But it's more complicated than removing tag. Here is a sample code.
import java.awt.*;
import java.io.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.text.html.*;
import javax.swing.text.BadLocationException;
public class JTextPaneTest extends JFrame {
private static
String testString = "This is a
test String which contains '<' and '>'.";
private javax.swing.JTabbedPane tabbedPane = new JTabbedPane();
private JTextPane htmlPane = new JTextPane();
private JTextPane sourcePane = new JTextPane();
private JTextPane plainTextPane = new JTextPane();
public JTextPaneTest() {
super("Test");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
htmlPane.setContentType("text/html");
htmlPane.setText(testString);
sourcePane.setText(htmlPane.getText());
tabbedPane.add("HTML", htmlPane);
tabbedPane.add("Source", sourcePane);
tabbedPane.add("PlainText", plainTextPane);
javax.swing.text.Document
doc = htmlPane.getDocument();
javax.swing.text.ElementIterator it = new javax.swing.text.ElementIterator(doc);
javax.swing.text.Element el = it.first();
try {
plainTextPane.setText(doc.getText(el.getStartOffset(),el.getEndOffset()));
} catch(Exception exc) {
}
getContentPane().setLayout(new BorderLayout());
getContentPane().add(tabbedPane, BorderLayout.CENTER);
setSize(500, 500);
show();
}
public static void main(String args[]) {
new JTextPaneTest();
}
}
If I simply remove all the tags, I will see "This is a test String which contains '≷' and '<'." instead of "This is a test String which contains '<' and '>'.";
Applogize for my English.
Renee