Search code examples
javajapplet

Multiple fill for a control


I want to fill a control to HORIZONTAL and the CENTER using GridBagLayout. I have tried using

this.setLayout(new GridBagLayout());
GridBagConstraints m=new GridBagConstraints();
m.fill=GridBagConstraints.HORIZONTAL;
m.anchor=GridBagConstraints.PAGE_START;
m.ipady=20;
m.weightx=0.5;
m.weighty=0.001;
add(pnlHeader,m);
m.fill=GridBagConstraints.HORIZONTAL|GridBagConstraints.VERTICAL;
m.anchor=GridBagConstraints.PAGE_END;
m.gridx=0;
m.weighty=1.0;
add(pnlBody,m);

This is what I get

enter image description here

I want the selected area to filled into the applet. Please How can I fill the second panel into the applet?.


Solution

  • Use

    m.fill = GridBagConstraints.BOTH;