Hi, this patch fixes PR 26842[0]. The fix to GapContent made another drawing problem visible which occured because document listeners have been registered twice. I prevented that by not indicating that the document has changed when someone changes the lineWrap or wrapStyleWord property and only update the view.
The ChangeLog:
2006-03-31 Robert Schuster <[EMAIL PROTECTED]>
* javax/swing/text/GapContent.java:
(replace): Move all Position instances from gap's end to
it's start before increasing the gap start.
* javax/swing/plaf/basic/BasicTextAreaUI.java:
(propertyChanged): Update the view only instead of
indicating a document change.
[0] - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26842
Index: javax/swing/text/GapContent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/GapContent.java,v
retrieving revision 1.43
diff -u -r1.43 GapContent.java
--- javax/swing/text/GapContent.java 29 Mar 2006 14:52:35 -0000 1.43
+++ javax/swing/text/GapContent.java 31 Mar 2006 15:17:58 -0000
@@ -644,10 +644,11 @@
System.arraycopy(addItems, 0, buffer, gapStart, addSize);
// Position objects having their mark at the end of the gap
- // (results in an offset of 0) should be moved down because
- // the size of the gap will decrease by addSize and the offsets
- // will increase by the same amount and the latter should not happen.
- resetMarksAtZero();
+ // (results in an offset equal to gapStart) should be moved down
+ // because the size of the gap will decrease by addSize and the
+ // offsets will increase by the same amount and the latter should
+ // not happen.
+ setPositionsInRange(gapEnd, 0, gapStart);
gapStart += addSize;
}
Index: javax/swing/plaf/basic/BasicTextAreaUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicTextAreaUI.java,v
retrieving revision 1.6
diff -u -r1.6 BasicTextAreaUI.java
--- javax/swing/plaf/basic/BasicTextAreaUI.java 31 Oct 2005 21:29:52 -0000 1.6
+++ javax/swing/plaf/basic/BasicTextAreaUI.java 31 Mar 2006 15:17:58 -0000
@@ -45,9 +45,11 @@
import javax.swing.JTextArea;
import javax.swing.UIDefaults;
import javax.swing.plaf.ComponentUI;
+import javax.swing.text.Document;
import javax.swing.text.Element;
import javax.swing.text.PlainView;
import javax.swing.text.View;
+import javax.swing.text.ViewFactory;
import javax.swing.text.WrappedPlainView;
public class BasicTextAreaUI extends BasicTextUI
@@ -108,6 +110,9 @@
JTextArea comp = (JTextArea)getComponent();
if (ev.getPropertyName() == "lineWrap"
|| ev.getPropertyName() == "wrapStyleWord")
- modelChanged();
+ {
+ // Changes the View (without modifying the document or it's listeners).
+ setView(create(textComponent.getDocument().getDefaultRootElement()));
+ }
}
}
signature.asc
Description: PGP signature
signature.asc
Description: OpenPGP digital signature
