From the application's Stage #1 create a new Stage #2 with Modality.APPLICATION_MODAL and owner Stage #1. From Stage #2 create a new Stage #3 with Modality.APPLICATION_MODAL and owner Stage #2. So that there is a stack of 3 windows [Stage #1, Stage #2 and Stage #3] in the windows ArrayList in com.sun.javafx.tk.quantum.GlassStage.windows. With Stage #3 visible, Stage #1 will be disabled with a disableCount of 2 and Stage #2 will be disabled with a disableCount of 1.
When Stage #3 is hidden GlassStage.windowsSetEnabled(true) will be called which will call com.sun.javafx.tk.quantum.WindowStage.setPlatformEnabled(true) which in turn will call platformWindow.setEnabled(true) which is in com.sun.glass.ui.Window for all the windows except for the one being hidden (Stage #3).
The problem occurs occurs in the WindowStage.setPlatformEnabled code as below :-
protected void setPlatformEnabled(boolean enabled) {
super.setPlatformEnabled(enabled);
platformWindow.setEnabled(enabled);
if (enabled) {
requestToFront();
} else {
removeActiveWindow(this);
}
}
because after the call platformWindow.setEnabled for Stage #1 the disableCount goes from 2 to 1 and hence Stage #1 is still disabled. However because enabled is true it calls requestToFront() which then causes the NSBeep in the Mac implentation code in GlassWindow+Overrides.m function windowDidBecomeKey:(NSNotification *)notification.
The easy fix is to just check if the window is enabled and only call requestToFront() if it is. The correct version of setPlatformEnabled is below :-
protected void setPlatformEnabled(boolean enabled) {
super.setPlatformEnabled(enabled);
platformWindow.setEnabled(enabled);
if (enabled) {
if (platformWindow.isEnabled()) { // Check if it is really enabled as might have been nested
requestToFront();
}
} else {
removeActiveWindow(this);
}
}
When Stage #3 is hidden GlassStage.windowsSetEnabled(true) will be called which will call com.sun.javafx.tk.quantum.WindowStage.setPlatformEnabled(true) which in turn will call platformWindow.setEnabled(true) which is in com.sun.glass.ui.Window for all the windows except for the one being hidden (Stage #3).
The problem occurs occurs in the WindowStage.setPlatformEnabled code as below :-
protected void setPlatformEnabled(boolean enabled) {
super.setPlatformEnabled(enabled);
platformWindow.setEnabled(enabled);
if (enabled) {
requestToFront();
} else {
removeActiveWindow(this);
}
}
because after the call platformWindow.setEnabled for Stage #1 the disableCount goes from 2 to 1 and hence Stage #1 is still disabled. However because enabled is true it calls requestToFront() which then causes the NSBeep in the Mac implentation code in GlassWindow+Overrides.m function windowDidBecomeKey:(NSNotification *)notification.
The easy fix is to just check if the window is enabled and only call requestToFront() if it is. The correct version of setPlatformEnabled is below :-
protected void setPlatformEnabled(boolean enabled) {
super.setPlatformEnabled(enabled);
platformWindow.setEnabled(enabled);
if (enabled) {
if (platformWindow.isEnabled()) { // Check if it is really enabled as might have been nested
requestToFront();
}
} else {
removeActiveWindow(this);
}
}
- duplicates
-
JDK-8088042 [Mac] Dismissing a modal dialog created by another modal dialog causes a beep
-
- Closed
-
-
JDK-8129581 [Mac] Child modal windows may beep when closing
-
- Closed
-