打开JDialog类时如何隐藏JFrame [英] How to hide a JFrame when a JDialog class is open

查看:84
本文介绍了打开JDialog类时如何隐藏JFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在打开JDialog框后隐藏JFrame,请使用addActionListener()来做到这一点

I am tring to Hide a JFrame when a JDialog box opened, please how doi do this usuing the addActionListener();

推荐答案

创建JDialog时,应将JFrame指定为对话框的所有者,然后可以使用对话框的getOwner()方法来获取该对话框.随时参考框架.

When you create a JDialog you should be specifying the JFrame as the owner of the dialog, then you can use the getOwner() method of the dialog to get the frame reference at any time.

在JDialog中,您应该可以使用WindowListener.

In you JDialog you should be able to use a WindowListener.

  1. windowOpened事件中,您隐藏了框架
  2. windowClosed事件中显示框架.
  1. In the windowOpened event you hide the frame
  2. in the windowClosed event you show the frame.

这篇关于打开JDialog类时如何隐藏JFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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