This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes getPrefferedSize setLayout(null) 0 0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "getPrefferedSize setLayout(null) 0 0" Watch "getPrefferedSize setLayout(null) 0 0" New topic
Author

getPrefferedSize setLayout(null) 0 0

Oczek Oczkowy
Greenhorn

Joined: Nov 01, 2006
Posts: 12
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?


fak de sys
Brian Cole
Author
Ranch Hand

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


bitguru blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getPrefferedSize setLayout(null) 0 0
 
Similar Threads
Simple: Turning A Program Into An Applet
placing image on jpanel and then add other components
focusing on radio button
Calling the repaint() method
array question