Thang Pham wrote:is there a particular reason that you declare IMAGE_PANEL, BUTTON_PANEL... to be static variables.
Those actually aren't variables. If you look closely you'll see that they are declared static final and are all-capitalized -- thus they are constants.
Second, can you explain a bit about the differences in setPreferredSize and setSize
Most layout managers will use the preferredSize value when deciding how to set a rendered component's size, not the size field, and so if you are using layout managers (and I suggest that you do so) it is the preferredSize field that
you should set.
If I want to keep the start button after I click it, how do I do it? I know CardLayout make it disappear, I try to implement BoxLayout to keep it, but the result was unsuccessful.
If you want to preserve the start button, then don't have it held by a component that is swapped by the cardlayout. For instance you could have your main JPanel use a BorderLayout, have it hold a JPanel in the BorderLayout.SOUTH position that holds your start button, and hold another JPanel in the BorderLayout.CENTER position that uses a CardLayout that swaps JPanels. The possibilities here are endless.
Again, thank you, and if any of my question appear to be stupid, please forgive me
You're quite welcome. And most of us here believe that the only stupid question is the unasked question. Best of luck.