Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JPanel

 
James Clarke
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

please read the code below:

JLabel jl = new JLabel("Facility Manager");
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();

c.gridx = 0;
c.gridy = 0;
panel.add(jl, c);
c.gridx = 0;
c.gridy = 1;
panel.add(tree,c); // tree is JTree

JScrollPane treeView = new JScrollPane(panel);

The each "box" of the panel takes 50% of the JScrollPane, I would rather that the first box only take up 10% and the second box take the rest....
Can someone direct me on how to do this ?

thanks,
J.C
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do you need it to be a GridBagLayout?

if not, it would be easier to use a BorderLayout, then add:
label to BorderLayout.NORTH
tree to BorderLayout.CENTER //will take 'the rest'
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!