Hi,
the attached patch fixes a problem which occured after my last patch when
someone tries to remove an empry string (e.g. gc.remove(0,0)). This happened
when calling setText on a JTextComponent for the first time (when there is no
text). The GapContent incorrectly throwed a BadLocationException which was then
swallowed in JTextComponent.setText.

I removed the incorrect expression which fired the exception and slightly
changed another. A check of all GapContent test shows that there are no
regressions. :)

The ChangeLog:

2006-05-02  Robert Schuster  <[EMAIL PROTECTED]>

        * javax/swing/text/JTextComponent.java:
        (setText): Throw InternalError from catch-block.
        * javax/swing/text/GapContent.java:
        (removed): Removed if-expression, changed '>' to '>='.

cya
Robert
Index: javax/swing/text/JTextComponent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/JTextComponent.java,v
retrieving revision 1.55
diff -u -r1.55 JTextComponent.java
--- javax/swing/text/JTextComponent.java	17 Mar 2006 21:44:19 -0000	1.55
+++ javax/swing/text/JTextComponent.java	2 May 2006 13:51:29 -0000
@@ -1191,6 +1191,7 @@
     catch (BadLocationException e)
       {
         // This can never happen.
+        throw (InternalError) new InternalError().initCause(e);
       }
   }
 
Index: javax/swing/text/GapContent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/GapContent.java,v
retrieving revision 1.45
diff -u -r1.45 GapContent.java
--- javax/swing/text/GapContent.java	2 May 2006 13:10:40 -0000	1.45
+++ javax/swing/text/GapContent.java	2 May 2006 13:51:29 -0000
@@ -376,14 +376,11 @@
   {
     // check arguments
     int length = length();
-
-    if (where >= length - 1)
-      throw new BadLocationException("the where argument cannot be greater"
-          + " or equal than the content length - 1", where);
-    if ((where + nitems) > length)
+    
+    if ((where + nitems) >= length)
       throw new BadLocationException("where + nitems cannot be greater"
           + " than the content length", where + nitems);
-
+    
     String removedText = getString(where, nitems);
     replace(where, nitems, null, 0);
 

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to