TacB0sS
TacB0sS

Reputation: 10266

Text is not fully shown in JTextField

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.

Upvotes: 3

Views: 1634

Answers (4)

TacB0sS
TacB0sS

Reputation: 10266

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

Upvotes: 0

camickr
camickr

Reputation: 324187

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

Upvotes: 0

static void main
static void main

Reputation: 738

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.

Upvotes: 1

brian_d
brian_d

Reputation: 11395

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

Upvotes: 3

Related Questions