views:

47

answers:

3

They say a single image is worth 1000 words:

alt text

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

Adam.

+2  A: 

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

brian_d
I know I can resize it manually, the point is to fit the text field width to the characters it holds, so default seemed like the right way for me. bottom line is that the default size is two pixels short. and I don't know why.
TacB0sS
+1  A: 

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.

Static Void Main
I thought that could be the case, any idea how to remove the border?
TacB0sS
A: 

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);
camickr