Java Swing Card Layout change the displayed Panel?
问题 so I have this jFrame with a Panel. Inside that panel there are two more panels and the layout is set to cards. Inside one of those two panels there is a button. How can I change the panel thats being displayed when that button is pressed? 回答1: Try this code snippet, hope the comments might help you understand the sequence. import java.awt.*; import java.awt.event.*; import javax.swing.*; /* Here we are first declaring our class that will act as the * base for other panels or in other terms