Hi, the attached patch fixes PR 27197. The reasons for the way it was done are explained in the source code as I think it may be of use for future developers.
The ChangeLog:
2006-05-15 Robert Schuster <[EMAIL PROTECTED]>
Fixes PR 27197.
* javax/swing/text/FieldView.java:
(paint): Calculate intersection between clip and allocation area and
set that as new clip.
cya
Robert
Index: javax/swing/text/FieldView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/FieldView.java,v
retrieving revision 1.16
diff -u -r1.16 FieldView.java
--- javax/swing/text/FieldView.java 3 May 2006 19:23:25 -0000 1.16
+++ javax/swing/text/FieldView.java 15 May 2006 15:38:57 -0000
@@ -50,6 +50,7 @@
import javax.swing.BoundedRangeModel;
import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
@@ -241,12 +242,29 @@
Shape newAlloc = adjustAllocation(s);
- // Set a clip to prevent drawing outside of the allocation area.
- // TODO: Is there a better way to achieve this?
Shape clip = g.getClip();
- g.setClip(s);
+ if (clip != null)
+ {
+ // Reason for this: The allocation area is always determined by the
+ // size of the component (and its insets) regardless of whether
+ // parts of the component are invisible or not (e.g. when the
+ // component is part of a JScrollPane and partly moved out of
+ // the user-visible range). However the clip of the Graphics
+ // instance may be adjusted properly to that condition but
+ // does not handle insets. By calculating the intersection
+ // we get the correct clip to paint the text in all cases.
+ Rectangle r = s.getBounds();
+ Rectangle cb = clip.getBounds();
+ SwingUtilities.computeIntersection(r.x, r.y, r.width, r.height, cb);
+
+ g.setClip(cb);
+ }
+ else
+ g.setClip(s);
+
super.paint(g, newAlloc);
g.setClip(clip);
+
}
public void insertUpdate(DocumentEvent ev, Shape shape, ViewFactory vf)
signature.asc
Description: OpenPGP digital signature
