• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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);
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic