WindowsTaskbar
Windows Taskbar is a java wrapper around the Windows native ITaskBarList3 interface with the help of JNA.
Install / Use
/learn @IcarusCoding/WindowsTaskbarREADME
Windows Taskbar
Windows Taskbar is a java wrapper around the Windows native ITaskBarList3 interface with the help of JNA.
Features
It currently supports the following features:
- Initialization of the COM library
- Creation of ThumbButtons
- Interception of the WM_COMMAND message from the window message loop
- Registration of click handlers which will get notified when a ThumbButton is clicked
- Support for custom icons
- Conversion of .ico files from the classpath or filesystem to native HICON instances
- Updating already existing ThumbButtons
- Java AWT integration
- JavaFX integration
How it looks

Prerequisites
Java 17 is required to use Windows Taskbar.
Getting Started
Adding Taskbar buttons with JavaFX
To use the library with JavaFX one has to retrieve the window handle to the active main window.
Currently one can use any of the following methods to retrieve such a handle after the JavaFX Stage is shown:
final Stage stage = ...;
var handle = WindowHandleFinder.getFromInternalJavaFX(stage);
var handle = WindowHandleFinder.getFromActiveWindow();
Adding Taskbar buttons with Java AWT
To use the library with Java AWT one has to retrieve the window handle to the active main window.
Currently one can use any of the following methods to retrieve such a handle after the AWT Window is shown:
final Component component = ...;
var handle = WindowHandleFinder.getFromInternalAWT(component);
final String windowTitle = ...;
var handle = WindowHandleFinder.findByName(windowTitle);
Using the library
final Icon testIcon = Icon.fromClassPath("test", "test.ico");
IWindowsTaskbar taskbar = TaskbarBuilder.builder()
.setHWnd(WindowHandleFinder.getFromInternalJavaFX(stage))
.autoInit()
.overrideWndProc()
.addButtons(ToolbarButtonListBuilder.builder()
.buttonBuilder()
.setIcon(testIcon)
.setTooltip("Click Me")
.withFlag(TaskbarButtonFlag.ENABLED)
.setOnClicked(evt -> System.out.println("Clicked on button with id " + evt.id()))
.build()
.buttonBuilder()
.setIcon(testIcon)
.setTooltip("Test Tooltip")
.withFlag(TaskbarButtonFlag.ENABLED)
.withFlag(TaskbarButtonFlag.DISMISS_ON_CLICK)
.build()
.build())
.build();
Remarks
A strong reference to an instance of the IWindowsTaskbar is needed, if an override of the standard window message loop of the used GUI library is desired.
