RFR: 8140527: JInternalFrame has incorrect title button width [v7]
Alexey Ivanov
aivanov at openjdk.org
Fri Jul 7 20:24:56 UTC 2023
On Fri, 7 Jul 2023 04:01:56 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> Title buttons under Widows Classic L&F got their sizes from the XP desktop theme in which button width can be bigger than height. It is construed as XP bug where sizes aren't updated properly so it uses height units for width for XP and later windows. The proposed fix uses the [same technique](https://github.com/openjdk/jdk/blob/a0595761ef35c4eec8cb84326a869b9473cd5bba/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsInternalFrameTitlePane.java#L78-L82) for Classic and forces title buttons to be square and to fit the frame title in height.
>>
>> Before fix SwingSet2 demo (Windows Classic InternalFrame)
>> 
>>
>> After fix
>> 
>
> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>
> Adjust width for Windows Vista theme to 32
The values in `UIManager` — `InternalFrame.titleButtonWidth` and `InternalFrame.titleButtonHeight` — come from Windows desktop properties, which are gotten from [`SystemParametersInfo`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-systemparametersinfow) called with `SPI_GETNONCLIENTMETRICS`, they are `iCaptionWidth` and `iCaptionHeight` members of the [`NONCLIENTMETRICS`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-nonclientmetricsw) structure.
https://github.com/openjdk/jdk/blob/292ee630ae32c3b50363b10ffa6090e57ffef1e8/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp#L299-L300
Interestingly, the returned values are 32×22 which don't match the width and height of any buttons. They may be correct for the Windows classic theme if it could be enabled.
I wonder if [`GetSystemMetrics`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics) with `SM_CXSIZE` and `SM_CYSIZE` gives the correct result. Yet it may be too late to change…
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14555#issuecomment-1626033157
More information about the client-libs-dev
mailing list