简体   繁体   English

Java“ java.awt.Window”数组在位置0添加项目

[英]Java “java.awt.Window” Array add Item at position 0

I have following code: 我有以下代码:

java.awt.Window win[] = java.awt.Window.getWindows();
for(int i=0;i<win.length;i++){
    win[i].dispatchEvent(new WindowEvent(win[i], WindowEvent.WINDOW_CLOSING));
} 

But my problem is that the first open window is closed at first. 但是我的问题是,首先关闭了第一个打开的窗口。 But I have to turn it around. 但是我必须扭转它。 How can I do this? 我怎样才能做到这一点?

Initialize i = (win.length - 1) and then make i count backwards instead. 初始化i = (win.length - 1) ,然后让i倒数。 End the loop when i >= 0 . i >= 0时结束循环。

Your question isn't very well worded, but if I understand correctly, this might work. 您的问题措辞不太好,但是如果我理解正确,这可能会起作用。

Like this: 像这样:

java.awt.Window win[] = java.awt.Window.getWindows();
for(int i = (win.length - 1); i >= 0; i--){
    win[i].dispatchEvent(new WindowEvent(win[i], WindowEvent.WINDOW_CLOSING));
} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM