Author | Topic: I am opening up this topic again..:) |
maha anna bartender |
posted March 02, 2000 03:35 PM
I was testing the 'monospaced' and 'variable' font concept. For this code I was expecting the TextField tf to show "12345" completely or 12345(partially truncated 5) because some spaces are eaten up by the leading and interspace between the chars. But what I am getting is a TextField of size >5 cols ,an extra trailing space like this "12345 ". The extra space easily accomodates another char. When I typed 6 , the whole "123456" is visible. I am using WIN98/jdk1.2.2 on a pentium m/c. Can anybody say anything upon this? Thank you . code: [This message has been edited by maha anna (edited March 02, 2000).]
|
Jim Yingst sheriff |
posted March 02, 2000 05:36 PM
Interesting. We previously discussed what happens with variable pitch fonts - I never thought to test the monospace version, as it seemed obvious. Evidently I was wrong. In fact, when I try your code using different values for the number of characters, I find that the text field always displays exactly one character more than what I specify. I mean, there's also a tiny bit of leading and trailing space, but I never see any potion of a number in ther, so I don't think that bit is really used at all - it's just there for appearance. But the fact that it's always off by 1 makes me think this is a bug. For what it's worth, I used jdk 1.2.2 and 1.3 beta on Win 98 with a Pentium III. Nonetheless, I think that for a test question, the correct answer would be that 5 columns are displayed. Even if reality is different.
|
PGautam greenhorn |
posted March 02, 2000 06:39 PM
Hi when we pass columns value as 5 to textfield constructor, does JVM restrict user from typing more than 5 characters.? I'll appreciate your reply. Thanks
|
Jim Yingst sheriff |
posted March 02, 2000 08:11 PM
What, after Maha Anna gave us that nice bit of sample code? Run it yourself and find out. Actually I think this is something that Java should have, but doesn't - an easy way to restrict the number of characters that a user puts into a text field / area. There are ways to do it, I think, but they're fairly complex. Like writing an event handler to intercept all input events to the text field, and only pass on those that don't extend the length past a certain maximum.
|
| | |