• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why does getWidth always return 0?  RSS feed

 
Unnar Björnsson
Ranch Hand
Posts: 164
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code is simple and is as follows:


The b1.getWidth() always returns 0 no matter what component I use. Why?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
before it is visible it has no dimensions

try it like this

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!