I implemented this method so that Lillian and myself can get more html
test apps working. This method is overridden in JEditorPane so that the
EditorKit can format as appropriate rather than just inserting plain
text.
2005-12-09 Anthony Balkissoon <[EMAIL PROTECTED]>
* javax/swing/JEditorPane.java:
(setText): Allow the EditorKit to read the text into the Document,
allowing for other than plain text.
--Tony
Index: javax/swing/JEditorPane.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JEditorPane.java,v
retrieving revision 1.29
diff -u -r1.29 JEditorPane.java
--- javax/swing/JEditorPane.java 8 Dec 2005 20:16:37 -0000 1.29
+++ javax/swing/JEditorPane.java 9 Dec 2005 19:26:00 -0000
@@ -43,6 +43,7 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
@@ -876,9 +877,36 @@
}
}
+ /**
+ * Sets the text of the JEditorPane. The argument <code>t</code>
+ * is expected to be in the format of the current EditorKit. This removes
+ * the content of the current document and uses the EditorKit to read in the
+ * new text. This allows the EditorKit to handle the String rather than just
+ * inserting in plain text.
+ *
+ * @param t the text to display in this JEditorPane
+ */
public void setText(String t)
{
- super.setText(t);
+ try
+ {
+ // Remove the current content.
+ Document doc = getDocument();
+ doc.remove(0, doc.getLength());
+ if (t == null || t == "")
+ return;
+
+ // Let the EditorKit read the text into the Document.
+ getEditorKit().read(new StringReader(t), doc, 0);
+ }
+ catch (BadLocationException ble)
+ {
+ // TODO: Don't know what to do here.
+ }
+ catch (IOException ioe)
+ {
+ // TODO: Don't know what to do here.
+ }
}
/**
_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches