Strange resizeing with Gr
 
  To: comp.lang.java.gui
Hi,
I'm using GridBagLayout to organize my components. Everything is
working fine.But if I resize the Frame I detected a strange behavior.
I have one panel on the left side and one panel on the right side.The
left panel should be 1/3 and the right on 2/3 of the frame size. If
the frame ist small (200X200) the size is ok. But if I resize the
frame to 800 X 600 the devision is nearly 1/2 to 1/2.
This hapends only if I have scrollPanels with tables in each panel.
Does anybody know this behavior.
Here is the source code:
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
public class TestPanel extends JPanel {
  GridBagLayout gridBagLayout1 = new GridBagLayout();
  JPanel ofPanel2 = new JPanel();
  JPanel ofPanel3 = new JPanel();
  GridBagLayout gridBagLayout2 = new GridBagLayout();
  GridBagLayout gridBagLayout3 = new GridBagLayout();
  JScrollPane jScrollPane1 = new JScrollPane();
  JScrollPane jScrollPane2 = new JScrollPane();
  JTable jTable1 = new JTable();
  JTable jTable2 = new JTable();
  /** Konstruktor */
  public TestPanel() {
    super();
    try {
      jbInit();
    }
    catch(RuntimeException l_ex) {
      throw l_ex;
    }
    catch(Exception l_ex) {
     l_exception.printStackTrace(System.out);
    }
  }
  public void eventAction(ActionEvent p_event, Object[] p_eventInfo) {
  }
  void jbInit() throws Exception {
    this.setLayout(gridBagLayout1);
    setComponentName();
    ofPanel2.setBackground(Color.green);
    ofPanel2.setLayout(gridBagLayout2);
    ofPanel3.setBackground(Color.yellow);
    ofPanel3.setLayout(gridBagLayout3);
    jScrollPane2.getViewport().setBackground(Color.blue);
    jScrollPane1.getViewport().setBackground(Color.cyan);
    this.add(ofPanel2,    new GridBagConstraints(0, 0, 1, 1, 0.5, 1.0
            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new
Insets(0, 0, 0, 0), 0, 0));
    ofPanel2.add(jScrollPane1,  new GridBagConstraints(0, 0, 1, 1, 1,
1.0
            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new
Insets(0, 0, 0, 0), 0, 0));
    jScrollPane1.getViewport().add(jTable1, null);
    this.add(ofPanel3,    new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0
            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new
Insets(0, 0, 0, 0), 0, 0));
    ofPanel3.add(jScrollPane2,   new GridBagConstraints(0, 0, 1, 1,
1.0, 1.0
            ,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new
Insets(0, 0, 0, 0), 0, 0));
    jScrollPane2.getViewport().add(jTable2, null);
  }
  public static void main(String[] p_args) {
    try {
      JFrame l_frame = new JFrame();
      TestPanel l_ctl;
      l_ctl = new TestPanel();
      l_frame.setContentPane(l_ctl);
      l_frame.setSize(l_ctl.getSize());
      l_frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent p_event) {
          System.exit(0);
        }
        ;
      });
      l_frame.setVisible(true);
      l_frame.pack();
    } catch (Throwable l_exception) {
      l_exception.printStackTrace(System.out);
    }
  }
  private void setComponentName() {
  }
}
---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24