• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to set the column to be showed by JTextField?  RSS feed

 
Samuel Chan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've already tried the following code but the showed column of the JTextField is not what I expected.
JTF1 = new javax.swing.JTextField(10); or
JTF2 = new javax.swing.JTextField();
JTF2.setColumns();
both show me about 15 columns.
I really don't know why this happened.
Thanks for any help!
 
Javaoops
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't u dig in this link.....
http://java.sun.com/docs/books/tutorial/uiswing/components/textfield.html
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Samuel,
In case you don't know, the TextField only holds an exact amount of columns for fixed sized fonts. For variable fonts, the resulting number of columns won't be exact. Therefore, if you are using a variable sized font and specifying 10 you will probably get a varying amount of columns depending on your font size. It will probably most of the time be more than you have specified, but not always!
Regards,
Manfred.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!