|
-
December 19th, 2011, 11:38 PM
#1
Need help with buttons...
Do you know why a JButton would take over the whole frame no matter what you set the size too? Like whatever I set my frame to, the button with is only suppose to 100,50 is still the size of a 500,500 frame. I do have 3 different buttons going into the JPanel object.
I have a hunch it has to do with how the JPanel is formatting these??? You have any input?
-
December 20th, 2011, 03:16 AM
#2
Re: Need help with buttons...
Laying out the components in a container is strictly married to the LayoutManager that is used. Frames contentpanes use BorderLayout by default, anything added to BorderLayout by calling single param add(Component component) is added to BorderLayout´s CENTER. If no other components are added, the single one will thus consume whole of the available space.
Use a LayoutManager that fits your purpose, check up on BoxLayout and FlowLayout.
Remember that you can use multiple LayoutManagers to construct wgat you want.
Remember that you can use transparent, non focusable components as fillers.
As a last resort, you can always override the getMaximumSize() and getMinimumSize() methods of a component. This you however should do, when there is ample reason to do so.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|