Window decorations: "full window content" mode
This PR brings "full window content" mode to FlatLaf window decorations on Windows 10/11 (and on Linux). For macOS see here.
Full window content mode allows you to extend the content into the window title bar. This means that the content pane (and glass pane) of the Swing window is extended into the window title bar. The window icon and title are automatically hidden. Only the minimize/maximize/close buttons stay visible. So your application can use (nearly) the whole window area.
The top area (same height as minimize/maximize/close buttons) can still be used to move the window (click-and-drag), maximize window (double-click), or show window menu (right-click). FlatLaf automatically detects components in that area that process mouse events and excludes them.
You can try out "full window content" mode in FlatLaf Demo. Press the "expand" button on the right side in the tab area (see red arrow):
The menu bar and toolbar are hidden (from the Demo; not automatically) so that the tabbed pane moves into the title bar area:
Note: If your application uses/requires a menu bar, it usually makes not much sense to use full window content mode.
How to enable
frame.getRootPane().putClientProperty( FlatClientProperties.FULL_WINDOW_CONTENT, true );
Buttons placeholder
To avoid that your components are overlapped by the minimize/maximize/close buttons, you need to add some placeholder component to the layout of your application. For Windows in the top-right corner (or top-left for right-to-left component orientation). A buttons placeholder is a JPanel that has client property FlatClientProperties.FULL_WINDOW_CONTENT_BUTTONS_PLACEHOLDER set.
Note that FlatLaf controls the preferred size of the placeholder panel. If fullWindowContent mode is enabled, it gets the size of the buttons area. Otherwise, the preferred size is 0, 0, which hides the placeholder.
JPanel placeholder = new JPanel();
placeholder.putClientProperty( FlatClientProperties.FULL_WINDOW_CONTENT_BUTTONS_PLACEHOLDER, "win" );
If you have a toolbar at top of your frame, use an additional panel that contains placeholder at EAST (or LINE_END) and toolbar in CENTER:
JToolBar toolBar = new JToolBar();
// add tool bar items
JPanel toolBarPanel = new JPanel( new BorderLayout() );
toolBarPanel.add( toolBar, BorderLayout.CENTER );
toolBarPanel.add( placeholder, BorderLayout.LINE_END );
frame.getContentPane().add( toolBarPanel, BorderLayout.NORTH );
See FlatClientProperties.FULL_WINDOW_CONTENT_BUTTONS_PLACEHOLDER javadoc for details.
For testing, you can make the placeholder "visible" with:
UIManager.put( "FlatLaf.debug.panel.showPlaceholders", true );
The red figure shows that placeholder bounds, the magenta figure the buttons bounds.
macOS
See https://www.formdev.com/flatlaf/macos/#full_window_content for details on how to enable full window content mode on macOS, which is provided by Java. See also PR #779 for larger close/minimize/zoom buttons spacing and usage of placeholder on macOS.
A snapshot for this PR is now available.
Use PR-801-SNAPSHOT as version.
https://github.com/JFormDesigner/FlatLaf#snapshots