classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] FYI: JTextComponent.CaretBlinkTimer fixlet


From: Mark Wielaard
Subject: [cp-patches] FYI: JTextComponent.CaretBlinkTimer fixlet
Date: Tue, 12 Jul 2005 11:06:04 +0200

Hi,

 From time to time the JTextComponent.CaretBlinkTimer would fire while
the caret was null. Resulting in nasty exceptions. This patch guards all
uses of caret in the Timer with a check to make sure the caret actually
exists.

2005-07-12  Mark Wielaard  <address@hidden>

        * javax/swing/text/JTextComponent.java
        (CaretBlinkTimer.actionPerformed): Check that caret != null.
        (CaretBlinkTimer.update): Likewise.

Committed,

Mark
Index: javax/swing/text/JTextComponent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/JTextComponent.java,v
retrieving revision 1.33
diff -u -r1.33 JTextComponent.java
--- javax/swing/text/JTextComponent.java        5 Jul 2005 10:22:42 -0000       
1.33
+++ javax/swing/text/JTextComponent.java        12 Jul 2005 09:04:33 -0000
@@ -322,7 +322,9 @@
      */
     public void actionPerformed(ActionEvent ev)
     {
-      caret.setVisible(!caret.isVisible());
+      Caret c = caret;
+      if (c != null)
+       c.setVisible(!c.isVisible());
     }
 
     /**
@@ -331,11 +333,15 @@
     public void update()
     {
       stop();
-      setDelay(caret.getBlinkRate());
-      if (editable)
-        start();
-      else
-        caret.setVisible(false);
+      Caret c = caret;
+      if (c != null)
+       {
+         setDelay(c.getBlinkRate());
+         if (editable)
+           start();
+         else
+           c.setVisible(false);
+       }
     }
   }
 

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


reply via email to

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