io.Connect Windows

In order for windows created from an external Java apps to become io.Connect Windows, they must first be registered via the Java Window Management API.

Registering Swing Windows

The Window Management API is accessible through

Currently, io.Connect 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 io.Connect Windows:

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

Controlling the Window

Once an app window is registered, io.Connect Windows will accept full control over the window position, size and visibility. The app shouldn't use native methods (for example, Swing calls) to control the window as this will interfere with the io.Connect Window management.

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


The window type is controlled by the mode window option which can be specified in the app definition or during window registration:, options -> options.mode(WindowMode.FLAT));


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

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

window.changeTitle("New Title");

Size & Position

To change the window bounds, use the changeBounds() method:

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


To hide or show the window, use the changeVisibility() method. Changing the window visibility also affects its associated icon:


Frame Buttons

You can add extra buttons in the frame area of the window and handle clicks for them.

Adding Buttons

To add a new button to the window frame, use the addFrameButton() method:

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

Removing Buttons

To remove a button from the window frame, use the removeFrameButton() method:

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

Window Events

The Java Window Management API offers methods for handling io.Connect Window events related to changes of the window title, bounds, visibility, context and more.


To subscribe for changes of the window title, use the onTitleChanged() method:

window.onTitleChanged(e -> System.out.println("Window title changed to: " + e.getTitle()));

Size & Position

To subscribe for changes of the window bounds, use the onBoundsChanged() method:

window.onBoundsChanged(e -> System.out.println("Window bounds changed to: " + e.getBounds()));


To subscribe for changes of the window visibility, use the onVisibilityChanged() method:

window.onVisibilityChanged(e -> System.out.println("Window is now " + (e.isVisible() ? "visible." : "hidden.")));


To subscribe for changes of the window focus, use the onFocusChanged() method:

window.onFocusChanged(e -> System.out.println("Window " + (e.isFocused() ? "is now on focus." : "has lost focus.")));


To subscribe for updates of the window context, use the onContextUpdated() method:

window.onContextUpdated(e -> System.out.println("Window context udpated: " + e.getContext()));

Frame Buttons

To subscribe for clicks on any frame buttons you may have added to the window, use the onFrameButtonClicked() method:

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


To prevent an io.Connect Window from closing, use the onClosing() method. The event handler callback must return asynchronously a PreventClosingOptions object whose methods you can use to specify the behavior of a window that is about to be closed.

The following example demonstrates how to prevent the window from closing and show a confirmation dialog to the user:

window.onClosing(() → CompletableFuture.supplyAsync(PreventClosingOptions :: dialog));

The PreventClosingOptions object has the following methods:

Method Description
allow() Will allow the window to close.
dialog() Will prevent the window from closing and will show a confirmation dialog to the user.
prevent() Will prevent the window from closing.