Yes, but what contains "mainPanel"? And how is mainPanel added to that container. Or is "mainPanel" the contentPane?
I have a more involved possibility but it involves the component that contains "mainPanel" more than it does "mainPanel" itself.
But, since you're saying that your adding "premade" Panels to mainPanel, then try this, as well:
Dimension d = mainPanel.getSiez();
mainPanel.removeAll();
mainPanel.add(addEP);
addEP.setPreferredSize(d);
addEP.setSize(d);
mainPanel.setPreferredSize(d);
mainPanel.setSize(d);
validate();
(and, if that works, you should probably be able to remove the two mainPanel.set*Size calls, but try including them, first).
Java Programmer and Sun Systems Administrator
----------------------------------------------
Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan