java JFrames
有没有办法让按钮只显示一次表单? 也就是说,我有两个 jframe(课程和主页);在一个 jframe(主页)上,我有一个 jbutton,当我单击它时,另一个 jframe 将打开(按钮事件中的代码:
课程框架=新课程() ; 框架.setVisible(true);
但问题是,我希望当 jframe 打开并在打开时再次单击按钮时,不要再次显示相同的表单,除非我关闭了打开的表单。
提前致谢
is there a way i could make a button display a form only once?
that is i have two jframe(courses and main page);at one jframe (main page),i have a jbutton that when i click on it the other jframe opens(the code at the button's event:
courses frame=new courses();
frame.setVisible(true);
but the issue is that i want when the jframe opens and i click on the button agin while it is open, not to display the the same form again not unless i have closed the opened one.
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要每次单击按钮时都
new course()
。 将变量作为主类中的字段。Don't
new courses()
everytime you click the button. Put the variable as a field in you main class.您应该将框架添加为类的成员,然后单击按钮时您可以执行以下操作:
You should add the frame as a member of the class, then when the button is clicked you can do: