File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How do you make the textfield and button the same size? FlowLayout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How do you make the textfield and button the same size? FlowLayout" Watch "How do you make the textfield and button the same size? FlowLayout" New topic
Author

How do you make the textfield and button the same size? FlowLayout

Ixus See
Ranch Hand

Joined: Jul 17, 2011
Posts: 160
Hello Guys,

I'm using Flow Layout for my search panel for some reason.. The Jtextfield and button is of different height, I have try setting the size and etc. but it doesn't work.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 4908
    
  10

Maybe that's just because JTextField and JButton are rendered with their default size. But I'll slide this over to the Swing forum for some expert advice.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18115
    
    8

If your primary goal is that two adjacent components should be exactly the same size, then GridLayout would be a better choice.
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1075
    
  10

Ixus See wrote:I have try setting the size and etc. but it doesn't work.


Did you set the preferredSize? also, what look & feel are you using?


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How do you make the textfield and button the same size? FlowLayout
 
Similar Threads
size of JButton
setting button size
How can I customised the Ok-Cancel Button in JOptionPane
JButton & setSize
How to display popup in JSF