I have here a sample of a program here. I have 3 panels and I want to stop the user in pressing the previous button if the panel is in panel_1 and also stop at the
Check out Card Layout Actions for a simple extension of the CardLayout.
It provides "Next" and "Previous" actions that you can use to create buttons or menu items and the Actions will automatically be disabled when you are at the end/beginning of the cards.