Window Decorations

This page is work in progress.

FlatLaf provides custom window decorations on Windows 10/11 (and on Linux).

Overview

Window decorations include the title bar at the top of a window and the border around the window. The title bar displays application icon, the window title, allows the user to move the window, and has buttons to minimize, maximize or close the window. The border allows resizing the window.

Operating system window decorations

A Swing application usually looks like this:

Windows 11

The white window title bar is painted and managed by the Windows 10/11 operating system. It is not possible to change the colors or put Swing components into the white area. The dark area is painted and managed by Swing.

FlatLaf window decorations

With FlatLaf window decorations enabled (the default on Windows 10/11), the operating system title bar is hidden and FlatLaf provides its own title bar (implemented in Swing), which gives full control over colors (and more):

FlatLaf

Operating system methods are used to minimize/maximize/move the window and to show the window system menu. This preserves operating system animations and special features like snapping.

The border around the window is still provided by Windows 10/11, which preserves special operating system features (e.g. snapping to top/bottom of screen) and animations when resizing the window.

Embedded menu bar

With enabled embedded menu bar (the default), FlatLaf automatically embedds the window menu bar into the title bar:

FlatLaf

This even allows adding own components into the title bar by adding them to the menu bar. See icon button between window title and minimize button in above screenshot.

Enable/disable

Windows 10/11

FlatLaf window decorations and embedded menu bar are enabled by default on Windows 10/11.

Use system property flatlaf.useWindowDecorations to disable window decorations for the whole application or client property JRootPane.useWindowDecorations for a single window.

Use system property flatlaf.menuBarEmbedded to disable embedded menu bar for the whole application or client property JRootPane.menuBarEmbedded for a single window.

Linux

FlatLaf window decorations can be also used on Linux, but they are disabled by default. To enable them in your app use following (before creating UI):

if( SystemInfo.isLinux ) {
    // enable custom window decorations
    JFrame.setDefaultLookAndFeelDecorated( true );
    JDialog.setDefaultLookAndFeelDecorated( true );
}

Warning: Do not use this if your application supports other look and feels (e.g. Windows L&F or Nimbus) and can switch to them without restarting the application. This would result in windows without decorations and the user would not be able to move or resize the windows.

Use system property flatlaf.menuBarEmbedded to disable embedded menu bar for the whole application or client property JRootPane.menuBarEmbedded for a single window.

macOS

FlatLaf window decorations and embedded menu bar are not available on macOS.

Java on macOS provides features to get dark window title bars (see appearance of window title bars) or to put Swing components into window title bar (see full window content).

The menu bar is usually at top of the screen (see screen menu bar).