mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-10 22:17:13 -06:00
Demo: added "Options > Show window title bar icon" to menu
This commit is contained in:
@@ -29,6 +29,7 @@ import java.util.prefs.Preferences;
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.DefaultEditorKit;
|
||||
import javax.swing.text.StyleContext;
|
||||
import com.formdev.flatlaf.FlatClientProperties;
|
||||
import com.formdev.flatlaf.FlatDarculaLaf;
|
||||
import com.formdev.flatlaf.FlatDarkLaf;
|
||||
import com.formdev.flatlaf.FlatIntelliJLaf;
|
||||
@@ -216,6 +217,7 @@ class DemoFrame
|
||||
|
||||
menuBarEmbeddedCheckBoxMenuItem.setEnabled( windowDecorations );
|
||||
unifiedTitleBarMenuItem.setEnabled( windowDecorations );
|
||||
showTitleBarIconMenuItem.setEnabled( windowDecorations );
|
||||
}
|
||||
|
||||
private void menuBarEmbeddedChanged() {
|
||||
@@ -228,6 +230,16 @@ class DemoFrame
|
||||
FlatLaf.repaintAllFramesAndDialogs();
|
||||
}
|
||||
|
||||
private void showTitleBarIcon() {
|
||||
boolean showIcon = showTitleBarIconMenuItem.isSelected();
|
||||
|
||||
// for main frame (because already created)
|
||||
getRootPane().putClientProperty( FlatClientProperties.TITLE_BAR_SHOW_ICON, showIcon );
|
||||
|
||||
// for other not yet created frames/dialogs
|
||||
UIManager.put( "TitlePane.showIcon", showIcon );
|
||||
}
|
||||
|
||||
private void underlineMenuSelection() {
|
||||
UIManager.put( "MenuItem.selectionType", underlineMenuSelectionMenuItem.isSelected() ? "underline" : null );
|
||||
}
|
||||
@@ -467,6 +479,7 @@ class DemoFrame
|
||||
windowDecorationsCheckBoxMenuItem = new JCheckBoxMenuItem();
|
||||
menuBarEmbeddedCheckBoxMenuItem = new JCheckBoxMenuItem();
|
||||
unifiedTitleBarMenuItem = new JCheckBoxMenuItem();
|
||||
showTitleBarIconMenuItem = new JCheckBoxMenuItem();
|
||||
underlineMenuSelectionMenuItem = new JCheckBoxMenuItem();
|
||||
alwaysShowMnemonicsMenuItem = new JCheckBoxMenuItem();
|
||||
animatedLafChangeMenuItem = new JCheckBoxMenuItem();
|
||||
@@ -731,6 +744,11 @@ class DemoFrame
|
||||
unifiedTitleBarMenuItem.addActionListener(e -> unifiedTitleBar());
|
||||
optionsMenu.add(unifiedTitleBarMenuItem);
|
||||
|
||||
//---- showTitleBarIconMenuItem ----
|
||||
showTitleBarIconMenuItem.setText("Show window title bar icon");
|
||||
showTitleBarIconMenuItem.addActionListener(e -> showTitleBarIcon());
|
||||
optionsMenu.add(showTitleBarIconMenuItem);
|
||||
|
||||
//---- underlineMenuSelectionMenuItem ----
|
||||
underlineMenuSelectionMenuItem.setText("Use underline menu selection");
|
||||
underlineMenuSelectionMenuItem.addActionListener(e -> underlineMenuSelection());
|
||||
@@ -877,6 +895,7 @@ class DemoFrame
|
||||
windowDecorationsCheckBoxMenuItem.setSelected( FlatLaf.isUseNativeWindowDecorations() );
|
||||
menuBarEmbeddedCheckBoxMenuItem.setSelected( UIManager.getBoolean( "TitlePane.menuBarEmbedded" ) );
|
||||
unifiedTitleBarMenuItem.setSelected( UIManager.getBoolean( "TitlePane.unifiedBackground" ) );
|
||||
showTitleBarIconMenuItem.setSelected( UIManager.getBoolean( "TitlePane.showIcon" ) );
|
||||
|
||||
if( JBRCustomDecorations.isSupported() ) {
|
||||
// If the JetBrains Runtime is used, it forces the use of it's own custom
|
||||
@@ -887,6 +906,7 @@ class DemoFrame
|
||||
unsupported( windowDecorationsCheckBoxMenuItem );
|
||||
unsupported( menuBarEmbeddedCheckBoxMenuItem );
|
||||
unsupported( unifiedTitleBarMenuItem );
|
||||
unsupported( showTitleBarIconMenuItem );
|
||||
}
|
||||
|
||||
if( SystemInfo.isMacOS )
|
||||
@@ -919,6 +939,7 @@ class DemoFrame
|
||||
private JCheckBoxMenuItem windowDecorationsCheckBoxMenuItem;
|
||||
private JCheckBoxMenuItem menuBarEmbeddedCheckBoxMenuItem;
|
||||
private JCheckBoxMenuItem unifiedTitleBarMenuItem;
|
||||
private JCheckBoxMenuItem showTitleBarIconMenuItem;
|
||||
private JCheckBoxMenuItem underlineMenuSelectionMenuItem;
|
||||
private JCheckBoxMenuItem alwaysShowMnemonicsMenuItem;
|
||||
private JCheckBoxMenuItem animatedLafChangeMenuItem;
|
||||
|
||||
@@ -375,6 +375,14 @@ new FormModel {
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "unifiedTitleBar", false ) )
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
|
||||
name: "showTitleBarIconMenuItem"
|
||||
"text": "Show window title bar icon"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showTitleBarIcon", false ) )
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
|
||||
name: "underlineMenuSelectionMenuItem"
|
||||
"text": "Use underline menu selection"
|
||||
|
||||
Reference in New Issue
Block a user