JavaFX Undecorated Window Task Icon Minimize

The JavaFX undecorated window gives you a blank canvas, giving freedom to how your window looks without having to accept the default Windows title bar and buttons such as the Minimize, Maximise and Close buttons.

On Windows, the disadvantage of the Undecorated stage is if you click on the icon on the Taskbar, you don’t get the minimise behaviour compared to other Windows app. Likewise, if you use the keyboard shortcut “Windows Key + M” all your apps except for the Undecorated JavaFX app will minimise.

This can be quite fustrating.

There is a stackoverflow post on this issue:

This answer from StackOverflow post seems to work

import com.sun.jna.Pointer;
import com.sun.jna.platform.win32.User32;
import com.sun.jna.platform.win32.WinDef;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import static com.sun.jna.platform.win32.WinUser.GWL_STYLE;

public class SimpleWindowApplication extends Application {

    public static void main(String[] args) {

    public void start(final Stage stage) {
        Scene scene = new Scene(new Pane(new Label("Hello World")));
        stage.setTitle("Find this window");
        long lhwnd =;
        Pointer lpVoid = new Pointer(lhwnd);
        WinDef.HWND hwnd = new WinDef.HWND(lpVoid);
        final User32 user32 = User32.INSTANCE;
        int oldStyle = user32.GetWindowLong(hwnd, GWL_STYLE);
        int newStyle = oldStyle | 0x00020000;//WS_MINIMIZEBOX
        user32.SetWindowLong(hwnd, GWL_STYLE, newStyle);

It uses the JNA library add the WS_MINIMIZEBOX style to the existing Window.

Dependencies required if your using gradle are

    compile ''
    compile ''

Java 9

Java 9 modularity adds stronger encapsulation, if you attempt to run the sample program under Java 9, you’ll get IllegalAccessError as the package is not visible to unnamed modules

To make the example run on Java 9 you will need to add this additional VM Option

Leave a Reply

Your email address will not be published. Required fields are marked *