Hi,
In GridBagLayout u got a lot of attributes for the gridbagconstraints class. u had to know the purpose of each of it.
just take a look at the piece of ur code which had been modified and hope it works....
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class gridbag extends JFrame
{
Container cont;
JPanel panel;
JScrollPane scrollpane;
GridBagLayout gridbag;
GridBagConstraints c;
gridbag()
{
cont = getContentPane();
panel = new JPanel();
scrollpane = new JScrollPane(panel);
gridbag = new GridBagLayout() ;
c = new GridBagConstraints() ;
cont.setLayout(gridbag);
c.gridx = 0;
c.gridy = 0;
c.fill = GridBagConstraints.BOTH ;
c.weightx = 1.0 ;
c.weighty = 1.0 ;
gridbag.setConstraints(scrollpane,c) ;
//cont.setLayout(new BorderLayout());
cont.add(scrollpane);
}
public static void main(
String a[])
{
gridbag g = new gridbag();
g.setSize(300,300);
g.setVisible(true);
}
}