aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes setting jbutton size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "setting jbutton size" Watch "setting jbutton size" New topic
Author

setting jbutton size

Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
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.




Scooby Snacks for everyone...<br /> <br />SCJA, SCJP 1.4
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
setPreferredSize() works, but only adjusts the height, not the width. the width still consumes the entire frame.
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
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.
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
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 ]

bitguru blog
Michael Raymond Jr.
Ranch Hand

Joined: May 16, 2005
Posts: 178
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...
 
Don't get me started about those stupid light bulbs.
 
subject: setting jbutton size