aspose file tools
The moose likes Beginning Java and the fly likes Setting Height and Width of JButtons Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Setting Height and Width of JButtons" Watch "Setting Height and Width of JButtons" New topic
Author

Setting Height and Width of JButtons

Graham Spice
Greenhorn

Joined: Nov 01, 2001
Posts: 5
Hello,
I'm trying to set the Height and Width of JButtons but for the life of me I can't get it going.
I've tried
button1.setSize(100,100);
but it doesn't seem to work.
Any clues?
Thanks.
Suresh Bansal
Ranch Hand

Joined: Jul 23, 2001
Posts: 91
Looks like layout manager is over riding your settings for the isze of JButton.
Try to put this statement.
setLayoutManager(null);


Journey is as important as the Destination.<br /> <br />PMP, SCJP, SCJD, SCEA (Part 1), SCMAD, SCDJWS
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Don't set the layout to null. Set the size using setMinimumSize(), setPreferredSize() methods inherited from JComponent. It takes a Dimension as parameter.
So the code would look like this:
button.setPreferredSize(new Dimension(100, 50));
I have yet to find setting the layout to null to be needed.
Graham Spice
Greenhorn

Joined: Nov 01, 2001
Posts: 5
Thanks for the responses,
I'll give them a try...
Graham
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Setting Height and Width of JButtons
 
Similar Threads
What's the best layout for this?
show dilog at bottom of the screen
JButton redimension itself
buttons display problem in IE and FireFox
howto fix the size of table ?