I'm wondering about this for quite a long time now.
I usually build my SWING programs by having a JFrame with a JPanel containing the window's content set as the content pane by setContentPane(). When I want my content to be replaced by another one (e.g. for getting a new mask after clicking a button) I call setContentPane() again and replace the content pane by another panel. But everytime I do this, I need to call repaint() after setContentPane() to make the change visible, so I created an own class I use for creating frames. This class extends JFrame and overrides setContentPane() like this:
@Override
public void setContentPane(Container c) {
super.setContentPane(c);
revalidate();
repaint();
}
Why is this not implemented in the default JFrame class? Do I maybe have a bad side effect by doing this?