Hi,
is there any way to return the name of the current JPanel in a CardLayout JPanel?
I would like to compare if the first JPanel in the CardLayout equals the current one.
CardLayout cl = (CardLayout)(steps.getLayout());
if(cl.first() == current JPanel in card layout)
//some code
As a samle code, you can use Suns one: http://java.sun.com/docs/books/tutorial/uiswing/examples/layout/CardLayoutDemoProject/src/layout/CardLayoutDemo.java
EDIT:
I solved it with:
Component c[] = steps.getComponents();
int i = 0;
int j = c.length;
while (i < j) {
if (c[0].isVisible())
{
// add what you want to do here
break;
}
else
i ++;
}
But if there is any easier way to do this, I would be more than glad to know it.
Edited by: Roxxor on Jan 4, 2009 2:53 PM