[英]Find all modal dialogs belonging to a frame
我需要能夠判斷應用程序中是否打開了任何模式對話框。 有什么辦法嗎?
解決方案好了,因此,根據公認的答案,這就是我想出的辦法來完成我需要的工作:
Window[] wins : myMainFrame.getOwnedWindows();
for(Window w : wins) {
if(w instanceof JDialog) {
JDialog jd = (JDialog)w;
if(jd.isModal() && jd.isVisible()) {
// back out of current operation (return null in my case)
return null;
}
}
也許您正在尋找調用Window的getOwnedWindows()
,並且從Window派生的所有類都將具有此方法,包括JFrame和JDialog。
但是我同意更多的環境會有所幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.