Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Layout Management

 
Sam Jason
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,
I have completed my GUI design but there are still sth confused about layout management. In the main jframe, I use a jpanel to include all the components (JButton, JLabel, JCombox) except the JTable, and add this jpanel to the jframe's
BorderLayout.NORTH, and add the jtable to the
BorderLayout.CENTRE. since the jpanel use the FlowLayout, when i mininize the JFrame, the representation of the JPanel will get mess up(some component just disappear since the jpanel don't resize itself in the v way). I want to use
the GridBagLayout for that but it is a little complex and not easy to extend (imagine i have to add new components to the jpanel in furture, i have to modifiy a lot).
any suggestion about the layout design?
thanks
 
Leonardo Wang
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can change the default layout(FlowLayout) to BorderLayout to fix the position of component.
I use a series of JPanels with BorderLayout in stead of GridbayLayout to control the position of components.
Hope this helps
 
Abhinav Anand
Ranch Hand
Posts: 113
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Although GridBagLayout is a bit tough to use, but it provides a lot of control over the appearance of your components. So I have used it as the main way of placing components in the main client panel. Just try it once. Once you get a hang of it, you will find out that the benifits of using GridBagLayout far outweights it's complexity.
Thanks,
 
Sai Prasad
Ranch Hand
Posts: 560
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe starting jdk1.2, default layout is BorderLayout for JPanel. Sam, I suggest adding another panel to include the JScrollPane which contains the JTable.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic