Detectar o tamanho do JPanel mude o ouvinte

public class ClassName extends JFrame implements ComponentListener {
    @Override
    public void componentResized(ComponentEvent e) {
       //set your code here
	}
}
Helpless Hawk