public static void main(String[] args) {
Robot robot = Util.createRobot();
Frame testFrame = new Frame("Test Frame");
testFrame.setSize(200, 200);
testFrame.addWindowStateListener(new WindowStateListener() {
@Override
public void windowStateChanged(WindowEvent e) {
listenerNotified.set(true);
synchronized (listenerNotified) {
listenerNotified.notifyAll();
}
}
});
testFrame.setVisible(true);
Frame mainFrame = new Frame("Main Frame");
mainFrame.setSize(200, 200);
mainFrame.setLocationRelativeTo(null);
mainFrame.setVisible(true);
Util.waitForIdle(robot);
try {
Util.clickOnComp(mainFrame, robot);
Util.waitForIdle(robot);
// NORMAL -> ICONIFIED
listenerNotified.set(false);
testFrame.setExtendedState(Frame.ICONIFIED);
Util.waitForIdle(robot);
Util.waitForCondition(listenerNotified, 2000);
if (!listenerNotified.get()) {
throw new RuntimeException("Test FAILED! Window state listener was not notified during NORMAL to" +
"ICONIFIED transition");
}
if (testFrame.getExtendedState() != Frame.ICONIFIED) {
throw new RuntimeException("Test FAILED! Frame is not in ICONIFIED state");
}
// ICONIFIED -> NORMAL
listenerNotified.set(false);
testFrame.setExtendedState(Frame.NORMAL);
Util.waitForIdle(robot);
Util.waitForCondition(listenerNotified, 2000);
if (!listenerNotified.get()) {
throw new RuntimeException("Test FAILED! Window state listener was not notified during ICONIFIED to" +
"NORMAL transition");
}
if (testFrame.getExtendedState() != Frame.NORMAL) {
throw new RuntimeException("Test FAILED! Frame is not in NORMAL state");
}
} finally {
testFrame.dispose();
mainFrame.dispose();
}
}
java类java.awt.event.WindowStateListener的实例源码
NormalToIconifiedTest.java 文件源码
项目:jdk8u_jdk
阅读 32
收藏 0
点赞 0
评论 0
Window.java 文件源码
项目:j2se_for_android
阅读 26
收藏 0
点赞 0
评论 0
public synchronized void addWindowStateListener(WindowStateListener l) {
if (l == null) {
return;
}
list.add(WindowStateListener.class, l);
}
Window.java 文件源码
项目:j2se_for_android
阅读 29
收藏 0
点赞 0
评论 0
public synchronized void removeWindowStateListener(WindowStateListener l) {
if (l == null) {
return;
}
list.remove(WindowStateListener.class, l);
}
Window.java 文件源码
项目:j2se_for_android
阅读 80
收藏 0
点赞 0
评论 0
public synchronized WindowStateListener[] getWindowStateListeners() {
return getListeners(WindowStateListener.class);
}
AWTEventMulticaster.java 文件源码
项目:cn1
阅读 29
收藏 0
点赞 0
评论 0
public static WindowStateListener add(WindowStateListener a, WindowStateListener b) {
return (WindowStateListener) addInternal(a, b);
}
AWTEventMulticaster.java 文件源码
项目:cn1
阅读 20
收藏 0
点赞 0
评论 0
public static WindowStateListener remove(WindowStateListener l, WindowStateListener oldl) {
return (WindowStateListener) removeInternal(l, oldl);
}
Window.java 文件源码
项目:cn1
阅读 84
收藏 0
点赞 0
评论 0
public void addWindowStateListener(WindowStateListener l) {
windowStateListeners.addUserListener(l);
}
Window.java 文件源码
项目:cn1
阅读 26
收藏 0
点赞 0
评论 0
public WindowStateListener[] getWindowStateListeners() {
return windowStateListeners.getUserListeners(new WindowStateListener[0]);
}
Window.java 文件源码
项目:cn1
阅读 28
收藏 0
点赞 0
评论 0
public void removeWindowStateListener(WindowStateListener l) {
windowStateListeners.removeUserListener(l);
}
AWTEventMulticaster.java 文件源码
项目:freeVM
阅读 26
收藏 0
点赞 0
评论 0
public static WindowStateListener add(WindowStateListener a, WindowStateListener b) {
return (WindowStateListener) addInternal(a, b);
}