Class FlatNativeWindowsLibrary
Note: This is private API. Do not use!
- Since:
- 3.1
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Colorstatic final intDWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattributestatic final intDWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattributestatic final intstatic final intstatic final intDWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattributestatic final intDWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattributestatic final intDWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preferencestatic final intDWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preferencestatic final intDWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preferencestatic final intDWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preferencestatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptionsstatic final intFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleandwmSetWindowAttributeBOOL(long hwnd, int attribute, boolean value) Invokes Win32 API methodDwmSetWindowAttribute()with aBOOLattribute value.static booleandwmSetWindowAttributeCOLORREF(long hwnd, int attribute, Color color) Invokes Win32 API methodDwmSetWindowAttribute()with aCOLORREFattribute value.static booleandwmSetWindowAttributeDWORD(long hwnd, int attribute, int value) Invokes Win32 API methodDwmSetWindowAttribute()with aDWORDattribute value.static longGets the Windows window handle (HWND) for the given Swing window.static longGets the Windows operating system build number.static booleanisLoaded()Checks whether native library is loaded/available.static booleansetWindowCornerPreference(long hwnd, int cornerPreference) Sets the rounded corner preference for the window.static String[]showFileChooser(Window owner, boolean open, String title, String okButtonLabel, String fileNameLabel, String fileName, String folder, String saveAsItem, String defaultFolder, String defaultExtension, int optionsSet, int optionsClear, FlatNativeWindowsLibrary.FileChooserCallback callback, int fileTypeIndex, String[] fileTypes, int[] retFileTypeIndex) static intshowMessageBox(long hwndParent, String text, String caption, int type) Shows a Windows message box MessageBox.static intshowMessageDialog(long hwndParent, int messageType, String title, String text, int defaultButton, String... buttons) Shows a modal Windows message dialog.
-
Field Details
-
DWMWCP_DEFAULT
public static final int DWMWCP_DEFAULTDWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preference- See Also:
-
DWMWCP_DONOTROUND
public static final int DWMWCP_DONOTROUNDDWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preference- See Also:
-
DWMWCP_ROUND
public static final int DWMWCP_ROUNDDWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preference- See Also:
-
DWMWCP_ROUNDSMALL
public static final int DWMWCP_ROUNDSMALLDWM_WINDOW_CORNER_PREFERENCE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_window_corner_preference- See Also:
-
DWMWA_USE_IMMERSIVE_DARK_MODE
public static final int DWMWA_USE_IMMERSIVE_DARK_MODEDWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute- Since:
- 3.3
- See Also:
-
DWMWA_BORDER_COLOR
public static final int DWMWA_BORDER_COLORDWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute- Since:
- 3.3
- See Also:
-
DWMWA_CAPTION_COLOR
public static final int DWMWA_CAPTION_COLORDWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute- Since:
- 3.3
- See Also:
-
DWMWA_TEXT_COLOR
public static final int DWMWA_TEXT_COLORDWMWINDOWATTRIBUTE see https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute- Since:
- 3.3
- See Also:
-
DWMWA_COLOR_DEFAULT
public static final int DWMWA_COLOR_DEFAULT- Since:
- 3.3
- See Also:
-
DWMWA_COLOR_NONE
public static final int DWMWA_COLOR_NONE- Since:
- 3.3
- See Also:
-
COLOR_NONE
- Since:
- 3.3
-
FOS_OVERWRITEPROMPT
public static final int FOS_OVERWRITEPROMPTFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_STRICTFILETYPES
public static final int FOS_STRICTFILETYPESFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_NOCHANGEDIR
public static final int FOS_NOCHANGEDIRFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_PICKFOLDERS
public static final int FOS_PICKFOLDERSFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_FORCEFILESYSTEM
public static final int FOS_FORCEFILESYSTEMFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_ALLNONSTORAGEITEMS
public static final int FOS_ALLNONSTORAGEITEMSFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_NOVALIDATE
public static final int FOS_NOVALIDATEFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_ALLOWMULTISELECT
public static final int FOS_ALLOWMULTISELECTFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_PATHMUSTEXIST
public static final int FOS_PATHMUSTEXISTFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_FILEMUSTEXIST
public static final int FOS_FILEMUSTEXISTFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_CREATEPROMPT
public static final int FOS_CREATEPROMPTFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_SHAREAWARE
public static final int FOS_SHAREAWAREFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_NOREADONLYRETURN
public static final int FOS_NOREADONLYRETURNFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_NOTESTFILECREATE
public static final int FOS_NOTESTFILECREATEFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_HIDEMRUPLACES
public static final int FOS_HIDEMRUPLACESFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_HIDEPINNEDPLACES
public static final int FOS_HIDEPINNEDPLACESFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_NODEREFERENCELINKS
public static final int FOS_NODEREFERENCELINKSFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_OKBUTTONNEEDSINTERACTION
public static final int FOS_OKBUTTONNEEDSINTERACTIONFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_DONTADDTORECENT
public static final int FOS_DONTADDTORECENTFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_FORCESHOWHIDDEN
public static final int FOS_FORCESHOWHIDDENFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_DEFAULTNOMINIMODE
public static final int FOS_DEFAULTNOMINIMODEFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_FORCEPREVIEWPANEON
public static final int FOS_FORCEPREVIEWPANEONFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
FOS_SUPPORTSTREAMABLEITEMS
public static final int FOS_SUPPORTSTREAMABLEITEMSFILEOPENDIALOGOPTIONS see https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/ne-shobjidl_core-_fileopendialogoptions- Since:
- 3.7
- See Also:
-
-
Constructor Details
-
FlatNativeWindowsLibrary
public FlatNativeWindowsLibrary()
-
-
Method Details
-
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 -
getHWND
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_ROUNDandDWMWCP_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 aBOOLattribute 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 aDWORDattribute value. See https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattribute- Since:
- 3.3
-
dwmSetWindowAttributeCOLORREF
Invokes Win32 API methodDwmSetWindowAttribute()with aCOLORREFattribute value. See https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/nf-dwmapi-dwmsetwindowattributeSupported since Windows 11 Build 22000.
- Since:
- 3.3
-
showFileChooser
public static String[] showFileChooser(Window owner, boolean open, String title, String okButtonLabel, String fileNameLabel, String fileName, String folder, String saveAsItem, String defaultFolder, String defaultExtension, int optionsSet, int optionsClear, FlatNativeWindowsLibrary.FileChooserCallback callback, int fileTypeIndex, String[] fileTypes, int[] retFileTypeIndex) Shows the Windows system file dialogs IFileOpenDialog or IFileSaveDialog.Note: This method blocks the current thread until the user closes the file dialog. It is highly recommended to invoke it from a new thread to avoid blocking the AWT event dispatching thread.
- Parameters:
owner- the owner of the file dialog; ornullopen- iftrue, shows the open dialog; iffalse, shows the save dialogtitle- text displayed in dialog title; ornullokButtonLabel- text displayed in default button; ornull. Use '&' for mnemonics (e.g. "&Choose"). Use '&&' for '&' character (e.g. "Choose && Quit").fileNameLabel- text displayed in front of the filename text field; ornullfileName- user-editable filename currently shown in the filename field; ornullfolder- current directory shown in the dialog; ornullsaveAsItem- file to be used as the initial entry in a Save As dialog; ornull. File name is shown in filename text field, folder is selected in view. To be used for saving files that already exist. For new files usefileName.defaultFolder- folder used as a default if there is not a recently used folder value available; ornull. Windows somewhere stores default folder on a per-app basis. So this is probably used only once when the app opens a file dialog for first time.defaultExtension- default extension to be added to file name in save dialog; ornulloptionsSet- options to set; seeFOS_*constantsoptionsClear- options to clear; seeFOS_*constantscallback- approve callback; ornullfileTypeIndex- the file type that appears as selected (zero-based)fileTypes- file types that the dialog can open or save. Pairs of strings are required for each filter. First string is the display name of the filter shown in the combobox (e.g. "Text Files"). Second string is the filter pattern (e.g. "*.txt", "*.exe;*.dll" or "*.*").retFileTypeIndex- returns selected file type (zero-based); array must be have one element- Returns:
- file path(s) that the user selected; an empty array if canceled;
or
nullon failures (no dialog shown) - Since:
- 3.7.1
-
showMessageDialog
public static int showMessageDialog(long hwndParent, int messageType, String title, String text, int defaultButton, String... buttons) Shows a modal Windows message dialog.For use in
FlatNativeWindowsLibrary.FileChooserCallbackonly.- Parameters:
hwndParent- the parent of the message boxmessageType- type of message being displayed:JOptionPane.ERROR_MESSAGE,JOptionPane.INFORMATION_MESSAGE,JOptionPane.WARNING_MESSAGE,JOptionPane.QUESTION_MESSAGEorJOptionPane.PLAIN_MESSAGEtitle- dialog box title; ornullto use title from parent windowtext- message to be displayeddefaultButton- index of the default button, which can be pressed using ENTER keybuttons- texts of the buttons. Use '&' for mnemonics (e.g. "&Choose"). Use '&&' for '&' character (e.g. "Choose && Quit").- Returns:
- index of pressed button; or -1 for ESC key
- Since:
- 3.7
-
showMessageBox
Shows a Windows message box MessageBox.For use in
FlatNativeWindowsLibrary.FileChooserCallbackonly.- Parameters:
hwndParent- the parent of the message boxtext- message to be displayedcaption- dialog box titletype- see MessageBox parameter uType- Returns:
- see MessageBox Return value
- Since:
- 3.7
-