problem switching JPanels in a contentPane center position

I have problems changing the JPanel at the center position of my frame's contentpane, what I do is I create a new JPanel instance with new properties(actually a subclass of JFrame) assign it to the contentPane center position but it does not display. all this is done in a event handler, this is to state between the states of the application can anyone help me out

publicvoid actionPerformed(ActionEvent ae){

if(ae.getSource()==transaction){

JPanel newpanel=new JPanel();

//even tried this.getContentPane().remove(oldPanel) still no good

this.getContentPane().add("Center",newPanel);// I was thinking it will do

}

}

[990 byte] By [mambenanjea] at [2007-10-2 8:45:45]
# 1

When adding or removing a component from a container you to use:

a) validate() on an AWT container

b) revalidate() on a Swing container

This will cause the LayoutManager to be invoked an lay out the components and repaint then correctly.

Another option is to use the [url http://java.sun.com/docs/books/tutorial/uiswing/layout/visual.html]Card Layout[/url] which was designed for this purpose.

camickra at 2007-7-16 22:48:14 > top of Java-index,Desktop,Core GUI APIs...