Window decorations: "full window content" mode #801
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
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 propertyFlatClientProperties.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.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:
See
FlatClientProperties.FULL_WINDOW_CONTENT_BUTTONS_PLACEHOLDER
javadoc for details.For testing, you can make the placeholder "visible" with:
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.