java如何关闭打开另一个框架的JFrame?
我有一个以welcomeScreen JFrame开始的程序,它有一个JButton,可以选择启动游戏。。当我点击该按钮时,它会打开游戏的JFrame,但不会关闭。。怎么做呢?我只知道这个系统。退出(0),这将关闭所有
你可以在下面搜索框中键入要查询的问题!
我有一个以welcomeScreen JFrame开始的程序,它有一个JButton,可以选择启动游戏。。当我点击该按钮时,它会打开游戏的JFrame,但不会关闭。。怎么做呢?我只知道这个系统。退出(0),这将关闭所有
# 1 楼答案
你可以试试:
jFrame.dispose();
# 2 楼答案
不要创建另一个
JFrame
在切换卡后,将
CardLayout
与JFrame.pack()
一起使用