In a complex situation the text in a JTextField is not properly clipped and therefore painted outside of the field's drawing area. To see the problem open the Swing Activity board, start the textfield demo and shrink the width of the internal frame until the horizontal scrollbar shows up. Suddenly you will see that the text is painted on the background of the desktop pane.
Created attachment 11292 [details] An image showing the clipping problem.
Created attachment 11314 [details] An image showing the JTextField bounds problem
Comment #2 refers to a similar problem where the text extends past the bounds of the JTextArea. In my case, I do not think that it requried that I resize the window.
Created attachment 11456 [details] a script demonstrating the problem this needs a custom version of JTextField
Created attachment 11457 [details] custom JTextField class for test script This custom JTextField class prints out the Graphics' clipping rectangle. The class is used by the test script.
Run the script, type f.show(), resize the JFrame and make the internal frame containing the textfield a bit bigger. When examining how the clipping rectangle changes (on the RI) when the internal frame is resized in a way that only parts of the textfield can be seen you'll notice that the rectangle gets smaller. I suppose that we need some additions to the code that calculates the clipping rectangle. @Roman: Can you tell me where such code has to be put?
OK, found out that this is a regression which I introduced with my patch for PR 27148. However taking it away would reopen that problem. It seems that calculating the intersection of the Graphics instances' clip and the allocation does the trick for both cases.
Fixed!
Subject: Bug 27197 CVSROOT: /cvsroot/classpath Module name: classpath Branch: Changes by: Robert Schuster <rschuster@savannah.gnu.org> 06/05/15 15:42:48 Modified files: javax/swing/text: FieldView.java . : ChangeLog Log message: 2006-05-15 Robert Schuster <robertschuster@fsfe.org> Fixes PR 27197. * javax/swing/text/FieldView.java: (paint): Calculate intersection between clip and allocation area and set that as new clip. CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/javax/swing/text/FieldView.java.diff?tr1=1.16&tr2=1.17&r1=text&r2=text http://cvs.savannah.gnu.org/viewcvs/classpath/classpath/ChangeLog.diff?tr1=1.7422&tr2=1.7423&r1=text&r2=text
The problem mentioned by david is fixed by PR 27148 (and still is as the code for this PR has not changed the behavior).