Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getPrefferedSize setLayout(null) 0 0

 
Oczek Oczkowy
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i have problem when i set my Jpanel layout to null (Jpanel.setLayout(null)) and i add there some buttons or different stuff my jpanel.getprefferdSize return 0 and i can not see my buttons. Do anybody have idea how to repair that?
 
Brian Cole
Author
Ranch Hand
Posts: 906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Oczek Oczkowy:
hi,
i have problem when i set my Jpanel layout to null (Jpanel.setLayout(null)) and i add there some buttons or different stuff my jpanel.getprefferdSize return 0 and i can not see my buttons. Do anybody have idea how to repair that?


Well that's what you should expect when you set your container's layout manager to null. The easiest way to 'repair' it is to use an actual
layout manager.

If you want the layout manager to remain null, which I don't recommend, you have to manually do what layout managers do. This includes setting a preferred size for your container and the bounds (size and position) of your buttons.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic