📜  java 切换显示面板 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:04.106000             🧑  作者: Mango

代码示例1
CardLayout cardLayout = new CardLayout();
JPanel mainPanel = new JPanel(cardLayout);

MenuPanel menu = new MenuPanel();
GamePanel game = new GamePanel();
mainPanel.add(menu, "menu");
mainPanel.add(game, "game");

...
public void gameOn() {
    cardLayout.show(mainPanel, "game");
}