• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

setting jbutton size

 
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can't change the default size of a jbutton. the button actually shows in the northern section, but takes up the entire width and i don't want it to.


 
Michael Raymond Jr.
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
setPreferredSize() works, but only adjusts the height, not the width. the width still consumes the entire frame.
 
Michael Raymond Jr.
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Raymond Jr.:
I can't change the default size of a jbutton. the button actually shows in the northern section, but takes up the entire width and i don't want it to.




never mind guys. i think i need to use flowlayout, but i'm just going to leave it as is. thanks anyways... moderator can delete this thread.
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Raymond Jr.:
I can't change the default size of a jbutton. the button actually shows in the northern section, but takes up the entire width and i don't want it to.




I know you said you said never mind but an obvious solution is, as you say, to use FlowLayout:

//button1.setMaximumSize(new Dimension(5,5));
JPanel flowNorth = new JPanel(); // defaults to centered FlowLayout
flowNorth.add(button1);
frame1.getContentPane().add(BorderLayout.NORTH, flowNorth);

[edit: oops, no need to set button's max size]
[ August 28, 2007: Message edited by: Brian Cole ]
 
Michael Raymond Jr.
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Brian Cole:


I know you said you said never mind but an obvious solution is, as you say, to use FlowLayout:

//button1.setMaximumSize(new Dimension(5,5));
JPanel flowNorth = new JPanel(); // defaults to centered FlowLayout
flowNorth.add(button1);
frame1.getContentPane().add(BorderLayout.NORTH, flowNorth);

[edit: oops, no need to set button's max size]

[ August 28, 2007: Message edited by: Brian Cole ]




i will probably change it in the near future. too lazy to update them now, but thanks for the response...
 
I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic