setFocus(btn1, robot);
setFocus(btn2, robot);
owner_frame.addWindowFocusListener(new WindowFocusListener() {
public void windowLostFocus(WindowEvent we) {
System.out.println(we);
}
public void windowGainedFocus(WindowEvent we) {
System.out.println(we);
throw new RuntimeException("owner frame must not receive WINDWO_GAINED_FOCUS");
}
});
window.addWindowFocusListener(new WindowFocusListener() {
public void windowLostFocus(WindowEvent we) {
System.out.println(we);
}
public void windowGainedFocus(WindowEvent we) {
System.out.println(we);
}
});
another_frame.addWindowFocusListener(new WindowFocusListener() {
public void windowLostFocus(WindowEvent we) {
System.out.println(we);
}
public void windowGainedFocus(WindowEvent we) {
System.out.println(we);