Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Which layout to use?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 4 buttons in my applicaiton, i have to arrange them in vertical. Through which layout i can do it? Please send me some sample code regarding.

Thanks.
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
new java.awt.GridLayout(4,1)
 
Sudharshan Reddy Ch
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, but using that the whole form will be occupied with the buttons. I want those buttons to display in center of my form.
 
Sudharshan Reddy Ch
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i got that, i used BoxLayout like this

panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));

and while adding the buttons

panel.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
panel.add(b1);
panel.add(Box.createRigidArea(new Dimension(0,5)));
panel.add(b2);
panel.add(Box.createRigidArea(new Dimension(0,5)));
panel.add(b3);
panel.add(Box.createRigidArea(new Dimension(0,5)));
panel.add(b4);
 
Time is mother nature's way of keeping everything from happening at once. And this is a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic