doLayout() is called by another method validate()
if you override validate() and do nothing, doLayout will not be called automatically.
import javax.swing.*;
import java.awt.*;
class testvalid extends JFrame
{
public testvalid()
{
super("testvalid");
getContentPane().setLayout(new GridLayout(3,1));
}
public void doLayout()
{
System.out.println("doLayout");
}
public void validate()
{
}
public static void main(String args[])
{
testvalid testvalidObj = new testvalid();
testvalidObj.setSize(400,400);
testvalidObj.pack();
testvalidObj.show();
}
}