[英]Restrict Access to other JFrame
How do i restrict access to other JFrame? 如何限制对其他JFrame的访问?
if I open my main frame and when click the button to display other jframe, the user should not be able to go back to the main frame. 如果打开主框架并单击该按钮以显示其他jframe,则用户应该无法返回主框架。
how do I do that? 我怎么做?
if i open my main frame and click the add button, 如果我打开主机并单击添加按钮,
When you click the button you display a modal JDialog. 单击按钮时,将显示模式JDialog。 Then until the user closes the dialog they won't be able to access the main frame. 然后,在用户关闭对话框之前,他们将无法访问主框架。
试试这个方法...
this.setEnabled(false);
Your question is not clear to me but as per my understanding I believe You want to open a dialog on button click but when you click the button a new JFrame is displayed and it becomes impossible for you to get back to the original frame. 我不清楚您的问题,但据我了解,我相信您想在单击按钮时打开一个对话框,但是当您单击按钮时,将显示一个新的JFrame,并且您将无法回到原始框架。
Use a dialog ( JDialog
class) instead and make it modal. 改用对话框( JDialog
类)并将其设置为模态。 Here is some help on how to do this: http://download.oracle.com/javase/tutorial/uiswing/components/dialog.html 这是有关如何执行此操作的帮助: http : //download.oracle.com/javase/tutorial/uiswing/components/dialog.html
Regards, 问候,
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.