This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

GridBagLayout not scales JTable to the desired Weightx value.  RSS feed

 
Aji Sree
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

My contentPane has BorderLayout.

I have added a panel with gridLayout.North.
I have one JTable inside a JScrollpane and another JPanel. I have added the scrollPane and JPanel(new GridLayout(2,1)) inside another panel which is having GridBagLayout.

This panel is added to the gridLayout.Center.

The problem is with the JScrollPane and Jpanel that I have added to the GridbagLayout panel.

I want JScrollPane 30 % of the whole page width and the JTable 70% of the whole page width.

I tried giving gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.BOTH;
gbc.weightx = .30;
gbc.weighty = 1; (when adding JScrollPane)

and gbc.gridx=1;
gbc.gridy=0;
gbc.weightx=200;
gbc.weighty=200;
gbc.fill = GridBagConstraints.BOTH;
gbc.weighty = 1; (When adding JPanel)

But it is not working fine. Especially the Jtable which is inside JScrollPane, is not increasing the width sufficiently. I want it to run in 800*600 resoluton, but the problem in display is more in that resolution.

Can anyone please help tpo find out a solution?

Thanks in advance
Ajith




 
Michael Dunn
Ranch Hand
Posts: 4632
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> The problem is with the JScrollPane and Jpanel that I have added to the GridbagLayout panel.
> I want JScrollPane 30 % of the whole page width and the JTable 70% of the whole page width.

perhaps the simplest way to get your 30/70 split is to use a JSplitPane.
set the divider location to where you want the split, then hide the divider
 
Aji Sree
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael,

Thank you very much for your reply.
JSplitPane seems suitable for my application.

Thank you
Ajith
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!