Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to add two buttons in each row?

 
Prakher Singhal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11092
13
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Prakher Singhal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic