• Post Reply Bookmark Topic Watch Topic
  • New Topic

BorderLayout NORTH - can i make it bigger?

 
Marcus Hathaway
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have several panels that i need to display on my frame. Using a BorderLayout to organise things, things appear to be displayed how i want them except that the panel added to BorderLayout NORTH seems too big. Only about half of the panel is being displayed. There is plenty of 'space' in BorderLayout CENTER for it to have, i assumed it would just take what it needed, with the panel occupying BorderLayout CENTER just moving down a tad. Is there a limit to how big the NORTH section can be? If so, any way of setting it to be that touch bigger?!

The solution of adding the panel that is currently in NORTH with the panel that is currently in CENTER, and then doing away with BorderLayout NORTH altogether works to some extent. However, i want a JTable to occupy the center panel on its own, as i like the appearance it gives when it has the freedom to fill the CENTER space without having to share with other components.

Any advice would be greatly appreciated,

Thanks!
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, there is no limit on how big the NORTH region can be. If it's not big enough, it's because the component didn't request enough space from the layout manager.

Perhaps the size of the component changed *after* the layout got calculated?
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The layout manager of the north panel computes the size requirements based on the child components. It reports this to the parent container. You can use the setPreferredSize method to alter the size reported by the JPanel.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!