Set specific size for JTextfield/Jbutton in BorderLayout?
can some one tell me how to set a specific size for JTextfield/JButton in Border/BoxLayout please?
I stried setSize, setPrefersize, setMAxsize, setMinsize, setBounds... but it won't work?
For example. If I add a jbutton to a jpanel, which has borderlayout, it will take up ALL the space in that jpanel.
Thanks
[335 byte] By [
Gurluvera] at [2007-11-26 16:16:18]

# 1
BorderLayout will stretch your components to fit the available size. Perhaps you could use FlowLayout. FlowLayout respects the preferred size of components. If you're adding many components, GridBagLayout can be configured to respect the preferred size of all its components.
# 2
Typically you use a BorderLayout for the high level layout and then add panels using other layouts to the BorderLayout. So for example on a simple dialog that is using a form that asks your for your first name and last name you would build a panel with those fields and add that panel to the center of the BorderLayout. Then you would create another panel for the "Ok" and "Cancel" buttons which would typically use a FlowLayout. Then you add that panel to the South of the BorderLayout.
The Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]How to Use LayoutManagers has all the information you need to know on using layout managers.