• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to set JButton Size  RSS feed

 
Andrew Parnell
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
how you change the size of a JButton?

thanks,
Andrew
 
Pat Hays
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew

If the container of the JButton is using null LayoutManager, then you can just call jButton1.setSize().
jButton1.setSize(new Dimension(83, 291));

If the container is using any LayoutManager, then
jButton1.setPreferredSize(new Dimension(83, 291));
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!