I'm having trouble figuring this one out.
The situation is no difficult to imagine so I hope I could post this without a sample code. I have JPanel with CardLayout. The panel contains several other panels as individual tabs. What I'm trying to achive is to create a JButton that will make the main panel show last opened tab (the one before the current was shown). No big deal I thought at first.
So I started by thinking how to get the current visible tab (panel) and found out that there is no native method for that in Panel or rather CardLayout that only contains methods first(), last(), next() and previous() which are no use to me.
Then I thought that maybe to achive my goal I might go through all components of the main panel and test which one is visible which would be the current one. I find it a little complicated, fine, but how do I make this panel show by CardLayout if I don't have its card name to call CardLayout method show(parent, name)?
At this point, I have no idea. I've been searching over the Internet but haven't found a solution, only that few people have been trying to figure something similar out. So I hope someone who already delt with this kind of issue comes across this topic :-)
Thanks for any suggestions.
Best regards
Martin S.