On Fri, 7 Jul 2023 04:01:56 GMT, Prasanta Sadhukhan <[email protected]> 
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)
>> ![image](https://github.com/openjdk/jdk/assets/43534309/3d6ec539-5e17-46ce-aba5-e724af6085fe)
>> 
>> After fix
>> ![image](https://github.com/openjdk/jdk/assets/43534309/db0135e4-d7f3-41a4-bbfa-e8e95cbd071d)
>
> 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

Reply via email to