如何在JFrames中使用setVisible? [英] How to use setVisible in JFrames?

查看:73
本文介绍了如何在JFrames中使用setVisible?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的程序中,我有两个 JFrame 实例。当我点击 next 按钮时,我想显示下一帧并隐藏当前帧。所以我使用 this.setVisible(false)和new Next()。setVisible(true)。但是在下一步窗口中,如果我点击返回按钮,我想将前一帧设置为再次可见,下一帧必须是结束(这意味着它必须退出)。

In my program I have two JFrame instances. When I click next button I want to show next frame and hide current frame. So I use this.setVisible(false) and new Next().setVisible(true). But in Next window if I click back button I want to set previous frame to be visible again and next frame must be ended (which means it must be exited).

有没有特殊方法可以做到这一点?我该怎么做?

Is there any special method(s) to do this? How can I do it?

推荐答案

考虑使用 CardLayout 而不是寻找多少 JFrames 。那么..

Consider using CardLayout instead of hunting for how many JFrames there are. Then..


  • 只需要一个JFrame

  • 任何Next / Back动作都将是只在牌之间切换

有很多此论坛中的示例 - 例如如图所示此处

There are lots of examples in this forum - e.g. as shown here.

这篇关于如何在JFrames中使用setVisible?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆