--- old/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp 2015-07-03 07:42:37.797909300 -0700 +++ new/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp 2015-07-03 07:42:37.500623600 -0700 @@ -31,6 +31,8 @@ #include "awt_Object.h" #include "awt_Component.h" +#include "math.h" + // Important note about VC6 and VC7 (or XP Platform SDK) ! // // These type definitions have been imported from UxTheme.h @@ -745,6 +747,19 @@ return NULL; } +void rescale(SIZE *size) { + HWND hWnd = ::GetDesktopWindow(); + HDC hDC = ::GetDC(hWnd); + float dpi = ::GetDeviceCaps(hDC, LOGPIXELSX); + + if (dpi !=0 && dpi != 96) { + float scale = dpi / 96; + size->cx = (int)ceil(size->cx / scale); + size->cy = (int)ceil(size->cy / scale); + } + ::ReleaseDC(hWnd, hDC); +} + /* * Class: sun_awt_windows_ThemeReader * Method: getPartSize @@ -770,6 +785,8 @@ dimMID = env->GetMethodID(dimClassID, "", "(II)V"); CHECK_NULL_RETURN(dimMID, NULL); } + + rescale(&size); jobject dimObj = env->NewObject(dimClassID, dimMID, size.cx, size.cy); if (safe_ExceptionOccurred(env)) { env->ExceptionDescribe();