开发者

Text is not fully shown in JTextField

They say a single image is worth 1000 words:

Text is not fully shown in JTextField

I'll just note that the size is set to default. (build in NetBeans) any idea how do I fix this?

Adam开发者_JAVA技巧.


Without you showing code, I'd say that your JTextField width is not set to be wide enough. You can resize it to be large enough for the number of characters you anticipate.

However, this does not guarantee that the user will not type in more characters, which would show the text cutoff as well.

You can extend the Document that JTextField uses to add the maximum character restriction, as shown at http://www.rgagnon.com/javadetails/java-0198.html


what are the lengths of your data,it seems you changed the layout and that's causing that problem as the border seems also occupying half of the character.


They say a single image is worth 1000 words:

Actually its not. When posting a question a SSCCE is worth 1000 words.

Stuff like that usually happens when you don't use a layout manager. Assuming (which is all we can do since you didn't post any code) that you are using a proper layout manager then your basic code for creating a text field to display 3 characters is:

JTextField width = new JTextField(3);


The reason is the LNF that was assigned to the frame, once I've changed that, it all works fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜