Skip to content

Windows Taskbar is a java wrapper around the Windows native ITaskBarList3 interface with the help of JNA.

Notifications You must be signed in to change notification settings

IcarusCoding/WindowsTaskbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

Test

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.

About

Windows Taskbar is a java wrapper around the Windows native ITaskBarList3 interface with the help of JNA.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages