File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple java layout question

 
Paul Statham
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,

I'm still getting used to layout managers etc, I have a JPanel that is quite large in size, I'm wanting to add another panel to it that looks something like below (the contents of the frame)



However when I add this Panel to a bigger Panel, it screws it



And here's the pretty simple test code I've been using



Thanks,
Paul
 
Rob Camick
Ranch Hand
Posts: 2476
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you add the panel to a BorderLayout the size of the component is automatcally changed to take up all the space in the BorderLayout. Since a GridLayout also expands to take up all the space all the components get resized. You can prevent this by wrapping your panel into another panel that uses a layout manager that respects the preferred size of the components. Something like this:

 
Paul Statham
Ranch Hand
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Camick wrote:When you add the panel to a BorderLayout the size of the component is automatcally changed to take up all the space in the BorderLayout. Since a GridLayout also expands to take up all the space all the components get resized. You can prevent this by wrapping your panel into another panel that uses a layout manager that respects the preferred size of the components. Something like this:



Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic