This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to add two buttons in each row? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to add two buttons in each row?" Watch "How to add two buttons in each row?" New topic
Author

How to add two buttons in each row?

Prakher Singhal
Greenhorn

Joined: Nov 06, 2008
Posts: 2
I am trying to build one GUI and want to add two buttons in each row of a panel.
I have added my source code. This java code will add buttons in Y-AXIS (one button in each row only).

Can somebuddy help me in it?
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10170
    
    8

Try out the GridLayout


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Prakher Singhal
Greenhorn

Joined: Nov 06, 2008
Posts: 2
Thankyou Maneesh,

I just tried GridLayout and its working fine but the size of the buttons are too big. How can I control the size of the buttons?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> How can I control the size of the buttons?

if you added a button to a JFrame (size 800,600),
the button would be (almost) the same size.

if you don't know how to control the size of that button,
then you need to read up on the layoutManager tutorials.

spoon-feeding you the answer to your question will not help you.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to add two buttons in each row?
 
Similar Threads
selectAll() method on a JTextArea
JTextArea page 415 of Head First Java
implementing ActionListener and ItemListener
Trials and tribulations, trys and catches
JList error