How to keep constant propotion using GridBagLayout
I am working with GridBagLayout. Now I have encountered a problem as follows.
I have a JPanel A.
On this JPanel A , I put two other JPanels,say JPanel B and JPanel C. One take the left side of A, one take the right side of A.
The propotion of width between B and C changes depending on what components in in B and C(precisely speaking, depends on the size of the components in B and C).
My task is to keep the propotion of width between B and C constant, say 2:1.
demo code illustrates the problem:
If the size of the button is set huge(delete the comment mark),the propotion of width between B and C changes accordingly. How can I conque this :) Thank you very much
JFrame frame=new JFrame();
JPanel A=new JPanel(new GridBagLayout());
JPanel B=new JPanel(new GridBagLayout());
GridBagConstraints c=new GridBagConstraints();
JPanel C=new JPanel(new GridBagLayout());
JButton bt=new JButton();
//bt.setPreferredSize(new Dimension(200, 40));