Class FlatNativeWindowsLibrary
- java.lang.Object
-
- com.formdev.flatlaf.ui.FlatNativeWindowsLibrary
-
public class FlatNativeWindowsLibrary extends java.lang.Object
Native methods for Windows.Note: This is private API. Do not use!
- Since:
- 3.1
-
-
Field Summary
Fields Modifier and Type Field Description private static int
API_VERSION_WINDOWS
static java.awt.Color
COLOR_NONE
static int
DWMWA_BORDER_COLOR
DWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattributestatic int
DWMWA_CAPTION_COLOR
DWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattributestatic int
DWMWA_COLOR_DEFAULT
static int
DWMWA_COLOR_NONE
static int
DWMWA_TEXT_COLOR
DWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattributestatic int
DWMWA_USE_IMMERSIVE_DARK_MODE
DWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattributestatic int
DWMWCP_DEFAULT
DWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preferencestatic int
DWMWCP_DONOTROUND
DWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preferencestatic int
DWMWCP_ROUND
DWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preferencestatic int
DWMWCP_ROUNDSMALL
DWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preferenceprivate static long
osBuildNumber
-
Constructor Summary
Constructors Constructor Description FlatNativeWindowsLibrary()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
dwmSetWindowAttributeBOOL(long hwnd, int attribute, boolean value)
Invokes Win32 API methodDwmSetWindowAttribute()
with aBOOL
attribute value.static boolean
dwmSetWindowAttributeCOLORREF(long hwnd, int attribute, java.awt.Color color)
Invokes Win32 API methodDwmSetWindowAttribute()
with aCOLORREF
attribute value.static boolean
dwmSetWindowAttributeDWORD(long hwnd, int attribute, int value)
Invokes Win32 API methodDwmSetWindowAttribute()
with aDWORD
attribute value.static long
getHWND(java.awt.Window window)
Gets the Windows window handle (HWND) for the given Swing window.static long
getOSBuildNumber()
Gets the Windows operating system build number.private static long
getOSBuildNumberImpl()
Invokes Win32 API methodGetVersionEx()
and returnsOSVERSIONINFO.dwBuildNumber
.static boolean
isLoaded()
Checks whether native library is loaded/available.static boolean
setWindowCornerPreference(long hwnd, int cornerPreference)
Sets the rounded corner preference for the window.
-
-
-
Field Detail
-
API_VERSION_WINDOWS
private static int API_VERSION_WINDOWS
-
osBuildNumber
private static long osBuildNumber
-
DWMWCP_DEFAULT
public static final int DWMWCP_DEFAULT
DWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preference- See Also:
- Constant Field Values
-
DWMWCP_DONOTROUND
public static final int DWMWCP_DONOTROUND
DWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preference- See Also:
- Constant Field Values
-
DWMWCP_ROUND
public static final int DWMWCP_ROUND
DWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preference- See Also:
- Constant Field Values
-
DWMWCP_ROUNDSMALL
public static final int DWMWCP_ROUNDSMALL
DWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preference- See Also:
- Constant Field Values
-
DWMWA_USE_IMMERSIVE_DARK_MODE
public static final int DWMWA_USE_IMMERSIVE_DARK_MODE
DWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute- Since:
- 3.3
- See Also:
- Constant Field Values
-
DWMWA_BORDER_COLOR
public static final int DWMWA_BORDER_COLOR
DWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute- Since:
- 3.3
- See Also:
- Constant Field Values
-
DWMWA_CAPTION_COLOR
public static final int DWMWA_CAPTION_COLOR
DWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute- Since:
- 3.3
- See Also:
- Constant Field Values
-
DWMWA_TEXT_COLOR
public static final int DWMWA_TEXT_COLOR
DWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute- Since:
- 3.3
- See Also:
- Constant Field Values
-
DWMWA_COLOR_DEFAULT
public static final int DWMWA_COLOR_DEFAULT
- Since:
- 3.3
- See Also:
- Constant Field Values
-
DWMWA_COLOR_NONE
public static final int DWMWA_COLOR_NONE
- Since:
- 3.3
- See Also:
- Constant Field Values
-
COLOR_NONE
public static final java.awt.Color COLOR_NONE
- Since:
- 3.3
-
-
Method Detail
-
isLoaded
public static boolean isLoaded()
Checks whether native library is loaded/available.Note: It is required to invoke this method before invoking any other method of this class. Otherwise, the native library may not be loaded.
-
getOSBuildNumber
public static long getOSBuildNumber()
Gets the Windows operating system build number.Invokes Win32 API method
GetVersionEx()
and returnsOSVERSIONINFO.dwBuildNumber
. See https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversionexa
-
getOSBuildNumberImpl
private static long getOSBuildNumberImpl()
Invokes Win32 API methodGetVersionEx()
and returnsOSVERSIONINFO.dwBuildNumber
. See https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversionexa
-
getHWND
public static long getHWND(java.awt.Window window)
Gets the Windows window handle (HWND) for the given Swing window.Note that the underlying Windows window must be already created, otherwise this method returns zero. Use following to ensure this:
or invoke this method after packing the window. E.g.if( !window.isDisplayable() ) window.addNotify();
window.pack(); long hwnd = getHWND( window );
-
setWindowCornerPreference
public static boolean setWindowCornerPreference(long hwnd, int cornerPreference)
Sets the rounded corner preference for the window. Allowed values areDWMWCP_DEFAULT
,DWMWCP_DONOTROUND
,DWMWCP_ROUND
andDWMWCP_ROUNDSMALL
.Invokes Win32 API method
DwmSetWindowAttribute(DWMWA_WINDOW_CORNER_PREFERENCE)
. See https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattributeSupported since Windows 11 Build 22000.
-
dwmSetWindowAttributeBOOL
public static boolean dwmSetWindowAttributeBOOL(long hwnd, int attribute, boolean value)
Invokes Win32 API methodDwmSetWindowAttribute()
with aBOOL
attribute value. See https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute- Since:
- 3.3
-
dwmSetWindowAttributeDWORD
public static boolean dwmSetWindowAttributeDWORD(long hwnd, int attribute, int value)
Invokes Win32 API methodDwmSetWindowAttribute()
with aDWORD
attribute value. See https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute- Since:
- 3.3
-
dwmSetWindowAttributeCOLORREF
public static boolean dwmSetWindowAttributeCOLORREF(long hwnd, int attribute, java.awt.Color color)
Invokes Win32 API methodDwmSetWindowAttribute()
with aCOLORREF
attribute value. See https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattributeSupported since Windows 11 Build 22000.
- Since:
- 3.3
-
-