• Post Reply Bookmark Topic Watch Topic
  • New Topic

size of button in gridlayout

 
Cathy Song
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JPanel with gridlayout (0, 2). I am adding a label in the first and button in the second column. The button resizes to cover the enter cell.

How can I set the size of the button? I have tried
setMaximumSize
setSize
setPreferredSize

nothign works
 
Pat Hays
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cathy

You may add a label in the first and a JPanel in the second column. The JPanel will resize to cover the enter cell. Then you add a button into that JPanel, and set the size of the button by setPreferredSize.
 
Pat Hays
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Btw, I could recommend you to use JFrameBuilder to try that. Quickly to see what's going on, and Quickly to get the GUI code generated for you.
 
Cathy Song
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks much!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!