• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextField size too big

 
praveen shinde
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello

I have added a jtextfield to a panel. But the size of the textfield is too big even if I set the size using JTextField tf = new JTextField(10).
Thanks
Praveen
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
debugging 101:

what layoutManager controls the textfield?
 
praveen shinde
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Michael,

I tried using 2 layouts.
When I use grid-layout the size of the component is too large where as it is too small for flow-layout
Thanks
Praveen
 
Rob Camick
Ranch Hand
Posts: 2619
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as it is too small for flow-layout


I have never seen a text field too small when using a FlowLayout. I believe the text field will be sized by using "W" as the width of each character. Since "W" is the widest character I dont' see how it can ever be too small.

Post your SSCCE that demonstrates the problem.
 
praveen shinde
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello

This is my code.



Thanks
Praveen
 
Rob Camick
Ranch Hand
Posts: 2619
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if I set the size using JTextField tf = new JTextField(10).


I don't see where you use "10" in your demo, so I don't understand your problem or your requirement.
 
praveen shinde
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could solve my problem.
Thanks a lot
Praveen
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Would you like to share how, so others may find it useful in the future?
 
buntha Choudhary
Ranch Hand
Posts: 136
Android Eclipse IDE Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On specifying the size of JTextField with FlowLayout , the scenario is working fine.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic