Window decorations: support enabling/disabling embedding menu bar via UI value at runtime

This commit is contained in:
Karl Tauber
2020-06-28 11:34:30 +02:00
parent 332f05b6e1
commit 6669d0e59d
3 changed files with 12 additions and 3 deletions

View File

@@ -28,6 +28,7 @@ import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.demo.extras.*;
import com.formdev.flatlaf.demo.intellijthemes.*;
import com.formdev.flatlaf.extras.FlatSVGIcon;
import com.formdev.flatlaf.ui.JBRCustomDecorations;
import net.miginfocom.swing.*;
/**
@@ -75,6 +76,11 @@ class DemoFrame
private void menuBarEmbeddedChanged() {
getRootPane().putClientProperty( FlatClientProperties.MENU_BAR_EMBEDDED,
menuBarEmbeddedCheckBoxMenuItem.isSelected() ? null : false );
// alternative method for all frames and menu bars in an application
// UIManager.put( "TitlePane.menuBarEmbedded", menuBarEmbeddedCheckBoxMenuItem.isSelected() );
// revalidate();
// repaint();
}
private void underlineMenuSelection() {
@@ -581,6 +587,9 @@ class DemoFrame
cutMenuItem.addActionListener( new DefaultEditorKit.CutAction() );
copyMenuItem.addActionListener( new DefaultEditorKit.CopyAction() );
pasteMenuItem.addActionListener( new DefaultEditorKit.PasteAction() );
menuBarEmbeddedCheckBoxMenuItem.setEnabled( UIManager.getLookAndFeel()
.getSupportsWindowDecorations() || JBRCustomDecorations.isSupported() );
}
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables