I am new to Java Swing. I am trying to do research on how to change pages within the same JFrame (within the same window to be specific.)
What I am trying to do is that there are 2 pages.
The first page has a list of select-able contents and a button that says "Next." Hitting the "next" button would create a new page based on the selected content.
On the new page, there is a "back" button that goes back to the original page, and the original page still remembers the the choice of selected content.
How would I approach this? I have looked up CardLayout, but I am not sure if that is the right technique.
Originally, I thought creating 2 classes, each a JFrame. The first class (first page) upon hitting "Next" button would instantiate the second class (second page.) The second page would be on top of the first page in the same window, like a stack.
On the second page, there is "Back" button which would call this.dispose(), which would get rid of the second page (popping off the stack) but leave first page intact. The problem however is that creating the second page results in a new, separate window instead of being in the same window as first page.
Again, how would I approach this?
By the way, I am aware having multiple JFrames is a bad practice The Use of Multiple JFrames: Good or Bad Practice?