wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes JTextField size too big Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextField size too big" Watch "JTextField size too big" New topic
Author

JTextField size too big

praveen shinde
Ranch Hand

Joined: Jun 03, 2009
Posts: 63
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

Joined: Jun 09, 2003
Posts: 4632
debugging 101:

what layoutManager controls the textfield?
praveen shinde
Ranch Hand

Joined: Jun 03, 2009
Posts: 63
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

Joined: Jun 13, 2009
Posts: 2155
    
    7
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

Joined: Jun 03, 2009
Posts: 63

Hello

This is my code.



Thanks
Praveen
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2155
    
    7
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

Joined: Jun 03, 2009
Posts: 63
I could solve my problem.
Thanks a lot
Praveen
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

Would you like to share how, so others may find it useful in the future?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
buntha Choudhary
Ranch Hand

Joined: Jul 03, 2009
Posts: 136

On specifying the size of JTextField with FlowLayout , the scenario is working fine.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextField size too big
 
Similar Threads
JTextField: How to limit the number of characters?
font problem in IE/FireFox
How to add two buttons in each row?
Using GridLayout/empty jTextFields appear too small
JTextField size