Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   Size of Button before show() (http://www.programmingforums.org/showthread.php?t=6026)

susam_pal Sep 22nd, 2005 9:19 AM

Size of Button before show()
 
:

JButton button = new JButton("Click here");
System.out.println(button.getWidth() + ";" + button.getHeight());


The output is always 0;0

Someone in the Yahoo Programming:1 room told me, that we must show() the frame before trying to determine the width and height. But I want to get the width and height of the button before showing the frame.

Can anyone solve my problem?

coldDeath Sep 22nd, 2005 10:24 AM

I think that yahoo guy was right, before you have shown it, it is just an object with no defined size, so the default width and height is 0.
Maybe you could show it on an area of the form which won't be seen.


All times are GMT -5. The time now is 12:37 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC