Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strange JTextField behavior

Status
Not open for further replies.

frag

Programmer
Dec 7, 2000
321
GB
Hi!

There is a strange thing with the JTextFields I use in my application. Let's say there is a textfield that was created like that:

Code:
private JTextField myTextField = new JTextField(20);

Running the application on different systems I get different results in the layout. With Windows 2000 the field is bigger than 20 (around 30) and in a solaris environment there is only room for about 19 characters. Can this be fixed in order to have the same size on both environments? I have the same problem with JTextArea!

Cheers

frag

patrick.metz@epost.de
 
I am using GridBagLayout... or are you talking of the UIManager? I have not set any look and feel, I am just using the default one.

patrick.metz@epost.de
 
ok if u use the gridbag constrains you should be able to force the text box to appear at a specified size, this should then work across any platform with a java virtual machine on, theoretically anyways!

if u are not sure about using gridbag have a look here:


Hope this is some use

Pete
 
The nr of columns you enter in the constructor of the JTextField is used to calculate the preferred width. The preferred width = the number of columns multiplied by the width of the letter m in the font selected into the text field. So maybe you have to look to the font...
 
Hm... I just can't figure out how to change the font and its size in a JTextField. Is that possible at all?

patrick.metz@epost.de
 
hologram,

my problem is not the method setFont(...) my problem is the method's parameter. It's the class 'Font' that I don't understand... but I will keep on trying

patrick.metz@epost.de
 
The sun site is my second home... but I always find it very hard to find the right information. Anyway I figured it out on my own in the meantime.

Thank you all very much... even if I have not really solved my column problem for the text field length yet. But I don't care any longer. ;-)

patrick.metz@epost.de
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top