diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java index be299934..f68a47c8 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java @@ -73,6 +73,16 @@ class DemoFrame } ); } + private void windowDecorationsChanged() { + boolean windowDecorations = windowDecorationsCheckBoxMenuItem.isSelected(); + + dispose(); + setUndecorated( windowDecorations ); + getRootPane().setWindowDecorationStyle( windowDecorations ? JRootPane.FRAME : JRootPane.NONE ); + menuBarEmbeddedCheckBoxMenuItem.setEnabled( windowDecorations ); + setVisible( true ); + } + private void menuBarEmbeddedChanged() { getRootPane().putClientProperty( FlatClientProperties.MENU_BAR_EMBEDDED, menuBarEmbeddedCheckBoxMenuItem.isSelected() ? null : false ); @@ -231,6 +241,7 @@ class DemoFrame JMenuItem incrFontMenuItem = new JMenuItem(); JMenuItem decrFontMenuItem = new JMenuItem(); JMenu optionsMenu = new JMenu(); + windowDecorationsCheckBoxMenuItem = new JCheckBoxMenuItem(); menuBarEmbeddedCheckBoxMenuItem = new JCheckBoxMenuItem(); underlineMenuSelectionMenuItem = new JCheckBoxMenuItem(); alwaysShowMnemonicsMenuItem = new JCheckBoxMenuItem(); @@ -466,6 +477,12 @@ class DemoFrame { optionsMenu.setText("Options"); + //---- windowDecorationsCheckBoxMenuItem ---- + windowDecorationsCheckBoxMenuItem.setText("Window decorations"); + windowDecorationsCheckBoxMenuItem.setSelected(true); + windowDecorationsCheckBoxMenuItem.addActionListener(e -> windowDecorationsChanged()); + optionsMenu.add(windowDecorationsCheckBoxMenuItem); + //---- menuBarEmbeddedCheckBoxMenuItem ---- menuBarEmbeddedCheckBoxMenuItem.setText("Embedded menu bar"); menuBarEmbeddedCheckBoxMenuItem.setSelected(true); @@ -588,12 +605,15 @@ class DemoFrame copyMenuItem.addActionListener( new DefaultEditorKit.CopyAction() ); pasteMenuItem.addActionListener( new DefaultEditorKit.PasteAction() ); - menuBarEmbeddedCheckBoxMenuItem.setEnabled( UIManager.getLookAndFeel() - .getSupportsWindowDecorations() || JBRCustomDecorations.isSupported() ); + boolean supportsWindowDecorations = UIManager.getLookAndFeel() + .getSupportsWindowDecorations() || JBRCustomDecorations.isSupported(); + windowDecorationsCheckBoxMenuItem.setEnabled( supportsWindowDecorations && !JBRCustomDecorations.isSupported() ); + menuBarEmbeddedCheckBoxMenuItem.setEnabled( supportsWindowDecorations ); } // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables private JMenu fontMenu; + private JCheckBoxMenuItem windowDecorationsCheckBoxMenuItem; private JCheckBoxMenuItem menuBarEmbeddedCheckBoxMenuItem; private JCheckBoxMenuItem underlineMenuSelectionMenuItem; private JCheckBoxMenuItem alwaysShowMnemonicsMenuItem; diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd index 7675da4c..0146ff6b 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd @@ -322,6 +322,15 @@ new FormModel { add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { name: "optionsMenu" "text": "Options" + add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) { + name: "windowDecorationsCheckBoxMenuItem" + "text": "Window decorations" + "selected": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "windowDecorationsChanged", false ) ) + } ) add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) { name: "menuBarEmbeddedCheckBoxMenuItem" "text": "Embedded menu bar" diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/FlatLafDemo.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/FlatLafDemo.java index 5e5bb17e..94e927d6 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/FlatLafDemo.java +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/FlatLafDemo.java @@ -16,6 +16,8 @@ package com.formdev.flatlaf.demo; +import javax.swing.JDialog; +import javax.swing.JFrame; import javax.swing.SwingUtilities; import com.formdev.flatlaf.extras.FlatInspector; import com.formdev.flatlaf.util.SystemInfo; @@ -36,6 +38,10 @@ public class FlatLafDemo SwingUtilities.invokeLater( () -> { DemoPrefs.init( PREFS_ROOT_PATH ); + // enable window decorations + JFrame.setDefaultLookAndFeelDecorated( true ); + JDialog.setDefaultLookAndFeelDecorated( true ); + // set look and feel DemoPrefs.initLaf( args );