On Mon, 3 Aug 2026 06:10:09 GMT, Prasanta Sadhukhan <[email protected]> wrote:
> In Aqua L&F, JOptionPane.showInternalMessageDialog does not close after > clicking the close icon button but other buttons like "OK" , "Cancel" works. > It seems `AquaInternalFrameBorder.doButtonAction()` which handles > `kCloseButton `was not called. > It is seen that `showInternalMessageDialog()` uses a modal JInternalFrame. > While that internal frame is modal, AWT filters mouse events so only the > modal frame’s contents/children can receive them. Aqua paints and handles the > red close button as part of the JInternalFrame border/title-bar itself via > AquaInternalFrameBorder. drawAllWidgets -> paintButton -> getWidget > (Widget.TITLE_BAR_CLOSE_BOX) > https://github.com/openjdk/jdk/blob/5b2d6991a1279d375f9a3c00c7bcd0bbcc7081d6/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameBorder.java#L393 > > When close button is presssed, the flow should be > https://github.com/openjdk/jdk/blob/5b2d6991a1279d375f9a3c00c7bcd0bbcc7081d6/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java#L528 > [records the button hit which delegates to the border] > https://github.com/openjdk/jdk/blob/5b2d6991a1279d375f9a3c00c7bcd0bbcc7081d6/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameUI.java#L536 > > https://github.com/openjdk/jdk/blob/5b2d6991a1279d375f9a3c00c7bcd0bbcc7081d6/src/java.desktop/macosx/classes/com/apple/laf/AquaInternalFrameBorder.java#L265 > > but it never gets called since > the click target was the modal JInternalFrame itself, not a child component, > so the modal filter consumed the event before Aqua code ever saw it, > > The fix is to allow events targeted at the modal component itself too > > It works for other L&F like Windows because they use Swing JButton for close > button component in the internal frame title pane. so the click target is a > child of the modal JInternalFrame, so the filter check is passed. > There doesn't seem to be a way to fix in macosx classes because Aqua never > receives the blocked event. The event is consumed earlier in shared AWT > lightweight-modal dispatch code so the fix is made there > CI testing is ok and no regression observed. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). As discussed, I have removed the close button from JOptionPane's JInternalFrame to ensure consistency for all L&Fs and also the "Close" menu JMenu is also removed [which was present in few L&F and not in others] from all JOptionPane's message type like JOptionPane.INFORMATION_MESSAGE, JOptionPane.PLAIN_MESSAGE etc Before fix <img width="374" height="285" alt="image" src="https://github.com/user-attachments/assets/7c730396-0b86-4b2e-9c29-2d4eee278ff5" /> After fix <img width="376" height="281" alt="image" src="https://github.com/user-attachments/assets/4498aacb-ac5e-42db-860a-1c96c10fb3c8" /> ------------- PR Comment: https://git.openjdk.org/jdk/pull/32169#issuecomment-5351815264
