• Post Reply Bookmark Topic Watch Topic
  • New Topic

resize buttons dynamically

 
Angela Stempfel
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
i have a application with a lot of buttons in it. If i resize the Apllication (frame) i would like to resize the buttons to.
How can i do that?
thanks
angela
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simple answer is to use a LayoutManager that does this... either GridLayout, GridBagLayout, or BorderLayout( or a misture of these and others ) could do what you want... How do you want your buttons laid out?

-Nate
 
Angela Stempfel
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello!
I have a JFrame which contains 3 JPanels. And one
of this JPanels has a lot of JButtons and Borders. These Buttons
and Borders should change the size if I resize the Application Frame.
If I change the Layout to GridLayout this doesn't look
well :-( . And I think it could really be hard to arrange all the components like they should be (i have an image as a template, at the end my panel should look like this image).
any idea?
angela
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Angela,
If you want to use only one layout manager then you better learn to use GridBagLayout. The only other solution is to use more than one layout manager (or misture as Nathan wrote...). For example, I can place a button inside a FlowLayout to get some insets around the button. Then I can place that layout inside a BorderLayout in the South section so that the Flow will be stretched the whole width of the outside frame.
GridBagLayout is so complex that it can mimic various other layout managers and can actually be made to have a little of each. You will probably have to play with it for a while to get it working the way you want. The great thing is that after you understand the GridBagLayout you don't really need any others!
Regards,
Manfred.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!