Hi,
it is really interesting how much influence a simple comparison operator can 
have.

This patch fixes the problem[0] I had with up & down movement in jtextareas by
prefering the first value in the comparison by using <= instead of <.

The ChangeLog:

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

        * javax/swing/text/Utilities.java:
        (getPositionAbove): Prefer first value by changing comparison
        from < to <=.
        (getPositionBelow): Dito.

cya
Robert

[0] - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26413
Index: javax/swing/text/Utilities.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/Utilities.java,v
retrieving revision 1.22
diff -u -r1.22 Utilities.java
--- javax/swing/text/Utilities.java	21 Feb 2006 13:56:15 -0000	1.22
+++ javax/swing/text/Utilities.java	22 Feb 2006 11:12:13 -0000
@@ -592,7 +592,7 @@
     int offsXNext = c.modelToView(offs+1).getLocation().x;
     
     // Chose the one which is nearer to us and return its offset.
-    if (Math.abs(offsX-x) < Math.abs(offsXNext-x))
+    if (Math.abs(offsX-x) <= Math.abs(offsXNext-x))
       return offs;
     else
       return offs+1;
@@ -629,14 +629,14 @@
     
     if (offs == c.getDocument().getLength())
       return offs;
-    
+
     // Find out the real x positions of the calculated character and its
     // neighbour.
     int offsX = c.modelToView(offs).getLocation().x;
     int offsXNext = c.modelToView(offs+1).getLocation().x;
     
     // Chose the one which is nearer to us and return its offset.
-    if (Math.abs(offsX-x) < Math.abs(offsXNext-x))
+    if (Math.abs(offsX-x) <= Math.abs(offsXNext-x))
       return offs;
     else
       return offs+1;

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to