-
Bug
-
Resolution: Fixed
-
P3
-
8u92, 9
-
b137
-
os_x
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8183735 | 8u161 | Anton Tarasov | P3 | Resolved | Fixed | b01 |
JDK-8165719 | 8u152 | Anton Tarasov | P3 | Resolved | Fixed | b01 |
JDK-8192472 | emb-8u161 | Anton Tarasov | P3 | Resolved | Fixed | b01 |
This is timing dependent, but it can happen that a modal dialog doesn't receive WINDOW_ACTIVATION & WINDOW_GAINED_FOCUS events when first shown. The following test forces "the right timings" & reproduces the bug:
public class Main {
public static void main(String[] args) throws InterruptedException {
EventQueue.invokeLater(() -> runGUI());
}
static void runGUI() {
JFrame f = new JFrame("frame");
JDialog d = new MyModalDialog(f, "dialog");
d.addWindowListener(new WindowAdapter() {
@Override
public void windowActivated(WindowEvent e) {
System.out.println(e);
}
});
d.addWindowFocusListener(new WindowAdapter() {
@Override
public void windowGainedFocus(WindowEvent e) {
System.out.println(e);
}
});
f.setVisible(true);
d.setVisible(true);
}
static class MyModalDialog extends JDialog {
public MyModalDialog(Frame owner, String title) {
super(owner, title, true);
}
@Override
public boolean getFocusableWindowState() {
try {
Thread.sleep(100);
} catch (InterruptedException ignore) {
}
return super.getFocusableWindowState();
}
}
}
public class Main {
public static void main(String[] args) throws InterruptedException {
EventQueue.invokeLater(() -> runGUI());
}
static void runGUI() {
JFrame f = new JFrame("frame");
JDialog d = new MyModalDialog(f, "dialog");
d.addWindowListener(new WindowAdapter() {
@Override
public void windowActivated(WindowEvent e) {
System.out.println(e);
}
});
d.addWindowFocusListener(new WindowAdapter() {
@Override
public void windowGainedFocus(WindowEvent e) {
System.out.println(e);
}
});
f.setVisible(true);
d.setVisible(true);
}
static class MyModalDialog extends JDialog {
public MyModalDialog(Frame owner, String title) {
super(owner, title, true);
}
@Override
public boolean getFocusableWindowState() {
try {
Thread.sleep(100);
} catch (InterruptedException ignore) {
}
return super.getFocusableWindowState();
}
}
}
- backported by
-
JDK-8165719 [macosx] modal dialog can skip the activation/focus events
-
- Resolved
-
-
JDK-8183735 [macosx] modal dialog can skip the activation/focus events
-
- Resolved
-
-
JDK-8192472 [macosx] modal dialog can skip the activation/focus events
-
- Resolved
-
- relates to
-
JDK-8181942 [TEST_BUG] test java/awt/Focus/ModalDialogActivationTest/ModalDialogActivationTest.java fails
-
- Open
-
-
JDK-8165157 [macosx] modal dialog is shown before it is expected
-
- Open
-