What's so special about CardLayout vs manual adding/removal of JPanels?
问题 There have been many times on StackOverflow where a user asks a question like this... I have a main JPanel that contains a child JPanel . When the user clicks a button, the child JPanel should change to a different JPanel . How can I achieve this. More often than not, the user has actually tried to implement this problem, but can't get it working. Whenever I answer this question, I tell them to do something like this (put simply)... JPanel myFrame = new JPanel(); myFrame.remove(oldPanel);