RFR: 8265586: [windows] last button is not shown in AWT Frame with BorderLayout and MenuBar set.

Harshitha Onkar honkar at openjdk.java.net
Fri Jun 10 06:05:46 UTC 2022


On Fri, 10 Jun 2022 05:55:35 GMT, Harshitha Onkar <honkar at openjdk.org> wrote:

> Due to incorrect AWT Frame inset values being returned from native code, few of the components in the frame were not being shown completely on Windows. With the proposed fix, correct insets are obtained which in turn sizes and displays the frame correctly.
> 
> The default insets obtained from the Win system was adding only `::GetSystemMetrics(SM_CXSIZEFRAME)` for **WS_THICKFRAME** and the insets were off by 6px from the expected value. `::GetSystemMetrics(SM_CXPADDEDBORDER)` is additionally added to top, bottom, left and right insets to account for the 6px. [GetSystemMetric() Document](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics)
> 
> A test case is added which checks if the actual frame size is equal to the expected frame size (frame.getSize() == frame.getPreferredSize()), thus checking if frame.pack() works as expected.
> 
> Following are before and after screenshots - 
> ![image](https://user-images.githubusercontent.com/95945681/172999272-981a0b07-2bd1-425c-b73d-f21f68922262.png)

src/java.desktop/windows/native/libawt/windows/awt_Window.cpp line 1407:

> 1405:     int extraPaddedBorderInsets = info.dwMajorVersion >= 6 ?
> 1406:      ::GetSystemMetrics(SM_CXPADDEDBORDER) : 0;
> 1407: 

The OS version check is added since **SM_CXPADDEDBORDER** metric is not supported on Win XP & 2000. If the current JDK Window target OS version is set to Windows Vista, probably this check is not required or redundant. Suggestions would be helpful as to whether to retain this check or not

![image](https://user-images.githubusercontent.com/95945681/173000377-4109fd09-f8e3-43a3-aa62-3d0c67d2ff56.png)
 
Screenshot source: [GetSystemMetrics Doc](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics)

-------------

PR: https://git.openjdk.org/jdk/pull/9118



More information about the client-libs-dev mailing list