mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 15:07:11 -06:00
Native window decorations: support disabling native window decorations per window via client property (issue #277)
This commit is contained in:
@@ -231,10 +231,28 @@ public interface FlatClientProperties
|
||||
|
||||
//---- JRootPane ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Specifies whether FlatLaf native window decorations should be used
|
||||
* when creating {@code JFrame} or {@code JDialog}.
|
||||
* <p>
|
||||
* Setting this to {@code false} disables using FlatLaf native window decorations
|
||||
* for the window that contains the root pane. Needs to be set before showing the window.
|
||||
* <p>
|
||||
* (requires Window 10)
|
||||
* <p>
|
||||
* <strong>Component</strong> {@link javax.swing.JRootPane}<br>
|
||||
* <strong>Value type</strong> {@link java.lang.Boolean}
|
||||
*
|
||||
* @since 1.1.1
|
||||
*/
|
||||
String USE_WINDOW_DECORATIONS = "JRootPane.useWindowDecorations";
|
||||
|
||||
/**
|
||||
* Specifies whether the menu bar is embedded into the title pane if custom
|
||||
* window decorations are enabled. Default is {@code true}.
|
||||
* <p>
|
||||
* (requires Window 10)
|
||||
* <p>
|
||||
* <strong>Component</strong> {@link javax.swing.JRootPane}<br>
|
||||
* <strong>Value type</strong> {@link java.lang.Boolean}
|
||||
*/
|
||||
|
||||
@@ -27,6 +27,7 @@ import javax.swing.JRootPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import com.formdev.flatlaf.FlatClientProperties;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.FlatSystemProperties;
|
||||
import com.formdev.flatlaf.ui.JBRCustomDecorations.JBRWindowTopBorder;
|
||||
@@ -99,6 +100,10 @@ public class FlatNativeWindowBorder
|
||||
if( window instanceof JFrame ) {
|
||||
JFrame frame = (JFrame) window;
|
||||
|
||||
// check whether disabled via client property
|
||||
if( !FlatClientProperties.clientPropertyBoolean( frame.getRootPane(), FlatClientProperties.USE_WINDOW_DECORATIONS, true ) )
|
||||
return;
|
||||
|
||||
// do not enable native window border if JFrame should use system window decorations
|
||||
// and if not forced to use FlatLaf/JBR native window decorations
|
||||
if( !JFrame.isDefaultLookAndFeelDecorated() &&
|
||||
@@ -119,6 +124,10 @@ public class FlatNativeWindowBorder
|
||||
} else if( window instanceof JDialog ) {
|
||||
JDialog dialog = (JDialog) window;
|
||||
|
||||
// check whether disabled via client property
|
||||
if( !FlatClientProperties.clientPropertyBoolean( dialog.getRootPane(), FlatClientProperties.USE_WINDOW_DECORATIONS, true ) )
|
||||
return;
|
||||
|
||||
// do not enable native window border if JDialog should use system window decorations
|
||||
// and if not forced to use FlatLaf/JBR native window decorations
|
||||
if( !JDialog.isDefaultLookAndFeelDecorated() &&
|
||||
|
||||
Reference in New Issue
Block a user