mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
Window decorations: support enabling/disabling embedding menu bar via UI value at runtime
This commit is contained in:
@@ -291,7 +291,7 @@ public class FlatRootPaneUI
|
||||
|
||||
@Override
|
||||
public void invalidateLayout( Container parent ) {
|
||||
if( titlePane != null && titlePane.isMenuBarEmbedded() )
|
||||
if( titlePane != null )
|
||||
titlePane.menuBarChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,6 @@ class FlatTitlePane
|
||||
private final Color inactiveForeground = UIManager.getColor( "TitlePane.inactiveForeground" );
|
||||
private final Color embeddedForeground = UIManager.getColor( "TitlePane.embeddedForeground" );
|
||||
|
||||
private final boolean menuBarEmbedded = UIManager.getBoolean( "TitlePane.menuBarEmbedded" );
|
||||
private final Insets menuBarMargins = UIManager.getInsets( "TitlePane.menuBarMargins" );
|
||||
private final Dimension iconSize = UIManager.getDimension( "TitlePane.iconSize" );
|
||||
private final int buttonMaximizedHeight = UIManager.getInt( "TitlePane.buttonMaximizedHeight" );
|
||||
@@ -321,7 +320,8 @@ class FlatTitlePane
|
||||
}
|
||||
|
||||
boolean isMenuBarEmbedded() {
|
||||
return menuBarEmbedded &&
|
||||
// not storing value of "TitlePane.menuBarEmbedded" in class to allow changing at runtime
|
||||
return UIManager.getBoolean( "TitlePane.menuBarEmbedded" ) &&
|
||||
FlatClientProperties.clientPropertyBoolean( rootPane, FlatClientProperties.MENU_BAR_EMBEDDED, true ) &&
|
||||
FlatSystemProperties.getBoolean( FlatSystemProperties.MENUBAR_EMBEDDED, true );
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user