Window Management


Glue42 Windows

In order for windows created from an external Java applications to become Glue42 windows, these windows must first be registered via the Java Window Management API.

Window Types

The window type is controlled by the mode window option which can be specified in the application definition or during window registration:

windows.register(handle, options -> options.mode(WindowMode.FLAT));

Registering a Swing Window

Currently, Glue42 Windows requires the underlying native handle (hwnd in the case of Windows) to be initialized and attached to the JFrame before the window can be registered. This is achieved internally through Glue42 Windows.

WindowManager windows =;
WindowHandle<JFrame> handle = windows.getWindowHandle(frame); 
        .thenAccept(window ->
                frame.addWindowListener(new WindowAdapter()
                    public void windowClosing(WindowEvent e)

Controlling the Window

Once an application window is registered, Glue42 Windows will accept full control over the window positioning, sizing and visibility. The application should not use native methods (for example, Swing calls) to control the window as it will interfere with the Glue42 window management.

The Java Window Management API allows you to control the following window properties:


The following example demonstrates how to set the window title during the window registration (this will ignore the title specified in the application configuration):, options -> options.title("My Title"));

To change the window title at runtime, use the changeTitle() method of a Glue42 Window instance and pass the new title as an argument:

window.changeTitle("New Title");

Size and Position

Change the window bounds:

window.changeBounds(new Bounds(10, 10, 200, 200));


Note that changing the window visibility also affects its associated icon:


Frame Buttons

You can put extra buttons in the frame area of the window and handle clicks for those buttons.

Adding a New Button

Use the addFrameButton() method to add a new button:

                              .image(new byte[0]) // needs to be a valid image
        .thenRun(() -> System.out.println("created button"));

Removing Button

Use removeFrameButton() to remove a button from the frame:

        .thenRun(() -> System.out.println("removed button"));

Handling Clicks

Use onFrameButtonClicked() to subscribe for button clicks:

window.onFrameButtonClicked(e -> {
    if ("search-button".equals(e.getButtonId()))
        System.out.println("Search button clicked");