The problem is that the panel will only cover as much area as it needs. Anything beyond this area is "ignored" during a validate on the panel (since that area no longer "belongs" to the Panel. 2 "quick" possibilites (I would try the second first).
Have you tried
Dimension d = mainPanel.getSiez();
mainPanel.removeAll();
mainPanel.add(addEP);
mainPanel.setPreferredSize(d);
mainPanel.setSize(d);
validate();
or
mainPanel.removeAll();
mainPanel.add(addEP);
mainPanel.getParent().validate();
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