classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] RFC: JTextArea text == null in constructor patch


From: Mark Wielaard
Subject: [cp-patches] RFC: JTextArea text == null in constructor patch
Date: Tue, 03 Jan 2006 20:57:51 +0100

Hi,

While playing with JEdit I encountered an exception because JEdit has a
JTextArea subclass that doesn't expect its overridden setText() method
to be called from the constructor. This patch makes it so:

2006-01-03  Mark Wielaard  <address@hidden>

    * javax/swing/JTextArea.java
    (JTextArea(Document,text,int,int)): Only call setText() when text is
    not null.

I think this is OK since text is often null when any of the other
constuctors is called that don't have a text argument (as in the JEdit
case). Does it look sane?

Cheers,

Mark


--- javax/swing/JTextArea.java  10 Oct 2005 19:14:04 -0000      1.18
+++ javax/swing/JTextArea.java  3 Jan 2006 19:57:52 -0000
@@ -217,7 +217,11 @@
   public JTextArea(Document doc, String text, int rows, int columns)
   {
     setDocument(doc == null ? createDefaultModel() : doc);
-    setText(text);
+    // Only explicitly setText() when there is actual text since
+    // setText() might be overridden and not expected to be called
+    // from the constructor (as in JEdit).
+    if (text != null)
+      setText(text);
     setRows(rows);
     setColumns(columns);
   }

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]