Bug 27197 - JTextField: text is improperly clipped
Summary: JTextField: text is improperly clipped
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: swing (show other bugs)
Version: 0.90
: P3 normal
Target Milestone: 0.92
Assignee: Robert Schuster
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-18 10:45 UTC by Robert Schuster
Modified: 2006-05-15 15:50 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-05-13 23:04:19


Attachments
An image showing the clipping problem. (9.28 KB, image/png)
2006-04-18 10:49 UTC, Robert Schuster
Details
An image showing the JTextField bounds problem (505 bytes, image/png)
2006-04-21 21:37 UTC, David Walluck
Details
a script demonstrating the problem (287 bytes, text/plain)
2006-05-13 21:54 UTC, Robert Schuster
Details
custom JTextField class for test script (351 bytes, text/plain)
2006-05-13 21:55 UTC, Robert Schuster
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Schuster 2006-04-18 10:45:39 UTC
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.
Comment 1 Robert Schuster 2006-04-18 10:49:15 UTC
Created attachment 11292 [details]
An image showing the clipping problem.
Comment 2 David Walluck 2006-04-21 21:37:37 UTC
Created attachment 11314 [details]
An image showing the JTextField bounds problem
Comment 3 David Walluck 2006-04-21 21:39:08 UTC
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.
Comment 4 Robert Schuster 2006-05-13 21:54:14 UTC
Created attachment 11456 [details]
a script demonstrating the problem

this needs a custom version of JTextField
Comment 5 Robert Schuster 2006-05-13 21:55:31 UTC
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.
Comment 6 Robert Schuster 2006-05-13 23:04:19 UTC
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?
Comment 7 Robert Schuster 2006-05-15 15:42:01 UTC
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.
Comment 8 Robert Schuster 2006-05-15 15:43:25 UTC
Fixed!
Comment 9 cvs-commit@developer.classpath.org 2006-05-15 15:44:38 UTC
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



Comment 10 Robert Schuster 2006-05-15 15:50:22 UTC
The problem mentioned by david is fixed by PR 27148 (and still is as the code for this PR has not changed the behavior).