Class FlatNativeWindowsLibrary


  • public class FlatNativeWindowsLibrary
    extends Object
    Native methods for Windows.

    Note: This is private API. Do not use!

    Since:
    3.1
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DWMWCP_DEFAULT
      DWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preference
      static int DWMWCP_DONOTROUND
      DWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preference
      static int DWMWCP_ROUND
      DWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preference
      static int DWMWCP_ROUNDSMALL
      DWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preference
    • Field Detail

      • 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
    • Constructor Detail

      • FlatNativeWindowsLibrary

        public FlatNativeWindowsLibrary()
    • Method Detail

      • isLoaded

        public static boolean isLoaded()
      • getOSBuildNumber

        public static long getOSBuildNumber()
        Gets the Windows operating system build number.

        Invokes Win32 API method GetVersionEx() and returns OSVERSIONINFO.dwBuildNumber. See https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getversionexa

      • getHWND

        public static long getHWND​(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:

        
         if( !window.isDisplayable() )
             window.addNotify();
         
        or invoke this method after packing the window. E.g.
        
         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 are DWMWCP_DEFAULT, DWMWCP_DONOTROUND, DWMWCP_ROUND and DWMWCP_ROUNDSMALL.

        Invokes Win32 API method DwmSetWindowAttribute(DWMWA_WINDOW_CORNER_PREFERENCE). See https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute

        Supported since Windows 11 Build 22000.

      • setWindowBorderColor

        public static boolean setWindowBorderColor​(long hwnd,
                                                   int red,
                                                   int green,
                                                   int blue)
        Sets the color of the window border. The red/green/blue values must be in range 0 - 255. If red is -1, then the system default border color is used (useful to reset the border color). If red is -2, then no border is painted.

        Invokes Win32 API method DwmSetWindowAttribute(DWMWA_BORDER_COLOR). See https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute

        Supported since Windows 11 Build 22000.