Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to put spaces between two buttons in Grid Layout?

 
Yuta Lolap
Ranch Hand
Posts: 86
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am working with grid layout for the first time. How do i put a space between two buttons here?
Please help me! It would solve a lot of issues!


I am designing a login form. And i wanted to put some space between the username button and the usernametxt. Posting a code of just buttons. Please do let me know.


Thanks in advance,
Yuta Lolap.
 
m Korbel
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
win.setLayout(new GridLayout(3, 2, 10, 10));, more in API
 
Yuta Lolap
Ranch Hand
Posts: 86
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
wat does 3,2,10,10 mean? What if i have to apply more space then which nos do i change?
 
Matthew Brown
Bartender
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you follow the link to the API that M Korbel provided? That explains what the parameters mean.
 
Yuta Lolap
Ranch Hand
Posts: 86
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it!
public GridLayout(int rows,
int cols,
int hgap,
int vgap)

But one more question the Hgap and Vgap , whats the measuring unit?
 
Yuta Lolap
Ranch Hand
Posts: 86
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do i fix the size of the button? When i re-size the frame to a larger resolution the button size also increases.
 
m Korbel
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
- GridLayout to take PreferredSize from JComponents is most largest / widest and the appply this PreferredSize for rest of elements

- in GridLayout all JComponents have got the same size on the screen
 
Yuta Lolap
Ranch Hand
Posts: 86
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you said is a little confusing. Do you mean to say that i cant specify fixed size at all?
 
Paul Clapham
Sheriff
Pie
Posts: 20775
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can specify a fixed size, and the buttons would all be that size. But you do that by specifying the size of the whole component. If that's still confusing, have a look at the API documentation for GridLayout (<== follow that link). It has pictures.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic