以编程方式关闭当前显示的 Java Swing JDialog 框 [英] Programatically closing currently displayed Java Swing JDialog box

查看:19
本文介绍了以编程方式关闭当前显示的 Java Swing JDialog 框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在开发一个对数据库执行搜索的 Java Swing 应用程序.它有两个在搜索过程中弹出的 JDialog 框.

Hi there I am working on an Java Swing application that performs a search on a database. It has 2 JDialog boxes that popup during the search.

第一个告诉用户搜索已经开始并且有一个确定按钮可以关闭.第二个告诉用户搜索已经返回并且也通过点击 OK 按钮关闭.

The first tells the user that the search has started and has an OK button to close. The second tells the user that the search has returned and is also closed by hitting the OK button.

我有一种以编程方式关闭第一个 JDialog 框的方法,当搜索返回时,很明显搜索返回时已经开始搜索.

I there a way of closing the first JDialog box programatically, when the search returns, it's it will be pretty obvious that the seach was started by the time the search has returned.

推荐答案

尽管关闭对话框就像在其上调用 setVisible(false) 一样简单,但我认为您的方法不是用户直观的.显示两个对话框是一种糟糕的 UI 做法.您需要做的是显示进度动画/对话框.搜索返回后,停止进度动画/对话框并显示返回的数据.以下是有关该主题的一些链接:

Even though closing dialog is as simple as calling setVisible(false) on it, I think your approach is not user intuitive. Showing two dialogs is a bad UI practice. What you have to do is to show progress animation/dialog. Once your search returns stop the progress animation/dialog and show the data returned. Here are some links about the subject:

http://java.sun.com/docs/books/tutorial/uiswing/components/progress.htmlhttp://developerlife.com/tutorials/?p=248

这篇关于以编程方式关闭当前显示的 Java Swing JDialog 框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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