CardLayout没有完全隐藏其他卡片?
我正在构建一个游戏,为了在登录屏幕和游戏屏幕之间切换,我使用了 CardLayout
。
我用来在屏幕之间切换的代码是
Global.gameScreen = new GameScreen(Global.connectionHandler.clientSocket);
cards.add(Global.gameScreen,"gameScreen");
((CardLayout)cards.getLayout()).show(cards,"gameScreen");
发生的情况,但在切换屏幕之后,如果我将鼠标移到登录屏幕中 Swing 控件所在的位置,它们就会出现,并且我可以与它们交互。
换卡有什么具体的方法吗?
I am building a game, and to switch between the login screen and the game screen, I am using a CardLayout
.
The code I am using to switch between the screens is
Global.gameScreen = new GameScreen(Global.connectionHandler.clientSocket);
cards.add(Global.gameScreen,"gameScreen");
((CardLayout)cards.getLayout()).show(cards,"gameScreen");
What happens, though is after I switch the screen, if I move my mouse over where the Swing controls in the login screen were, they appear and I can interact with them.
Is there a specific way I should switch cards?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来解决问题,但这对我有用。
我通过简单地添加“我不知道这是否是解决问题的正确方法”
I solved the problem by simply adding
I don't know if this is the right way to solve it, but it worked for me.