mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-15 08:17:12 -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.*;
|
||||||
import javax.swing.text.DefaultEditorKit;
|
import javax.swing.text.DefaultEditorKit;
|
||||||
import javax.swing.text.StyleContext;
|
import javax.swing.text.StyleContext;
|
||||||
|
import com.formdev.flatlaf.FlatClientProperties;
|
||||||
import com.formdev.flatlaf.FlatDarculaLaf;
|
import com.formdev.flatlaf.FlatDarculaLaf;
|
||||||
import com.formdev.flatlaf.FlatDarkLaf;
|
import com.formdev.flatlaf.FlatDarkLaf;
|
||||||
import com.formdev.flatlaf.FlatIntelliJLaf;
|
import com.formdev.flatlaf.FlatIntelliJLaf;
|
||||||
@@ -216,6 +217,7 @@ class DemoFrame
|
|||||||
|
|
||||||
menuBarEmbeddedCheckBoxMenuItem.setEnabled( windowDecorations );
|
menuBarEmbeddedCheckBoxMenuItem.setEnabled( windowDecorations );
|
||||||
unifiedTitleBarMenuItem.setEnabled( windowDecorations );
|
unifiedTitleBarMenuItem.setEnabled( windowDecorations );
|
||||||
|
showTitleBarIconMenuItem.setEnabled( windowDecorations );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void menuBarEmbeddedChanged() {
|
private void menuBarEmbeddedChanged() {
|
||||||
@@ -228,6 +230,16 @@ class DemoFrame
|
|||||||
FlatLaf.repaintAllFramesAndDialogs();
|
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() {
|
private void underlineMenuSelection() {
|
||||||
UIManager.put( "MenuItem.selectionType", underlineMenuSelectionMenuItem.isSelected() ? "underline" : null );
|
UIManager.put( "MenuItem.selectionType", underlineMenuSelectionMenuItem.isSelected() ? "underline" : null );
|
||||||
}
|
}
|
||||||
@@ -467,6 +479,7 @@ class DemoFrame
|
|||||||
windowDecorationsCheckBoxMenuItem = new JCheckBoxMenuItem();
|
windowDecorationsCheckBoxMenuItem = new JCheckBoxMenuItem();
|
||||||
menuBarEmbeddedCheckBoxMenuItem = new JCheckBoxMenuItem();
|
menuBarEmbeddedCheckBoxMenuItem = new JCheckBoxMenuItem();
|
||||||
unifiedTitleBarMenuItem = new JCheckBoxMenuItem();
|
unifiedTitleBarMenuItem = new JCheckBoxMenuItem();
|
||||||
|
showTitleBarIconMenuItem = new JCheckBoxMenuItem();
|
||||||
underlineMenuSelectionMenuItem = new JCheckBoxMenuItem();
|
underlineMenuSelectionMenuItem = new JCheckBoxMenuItem();
|
||||||
alwaysShowMnemonicsMenuItem = new JCheckBoxMenuItem();
|
alwaysShowMnemonicsMenuItem = new JCheckBoxMenuItem();
|
||||||
animatedLafChangeMenuItem = new JCheckBoxMenuItem();
|
animatedLafChangeMenuItem = new JCheckBoxMenuItem();
|
||||||
@@ -731,6 +744,11 @@ class DemoFrame
|
|||||||
unifiedTitleBarMenuItem.addActionListener(e -> unifiedTitleBar());
|
unifiedTitleBarMenuItem.addActionListener(e -> unifiedTitleBar());
|
||||||
optionsMenu.add(unifiedTitleBarMenuItem);
|
optionsMenu.add(unifiedTitleBarMenuItem);
|
||||||
|
|
||||||
|
//---- showTitleBarIconMenuItem ----
|
||||||
|
showTitleBarIconMenuItem.setText("Show window title bar icon");
|
||||||
|
showTitleBarIconMenuItem.addActionListener(e -> showTitleBarIcon());
|
||||||
|
optionsMenu.add(showTitleBarIconMenuItem);
|
||||||
|
|
||||||
//---- underlineMenuSelectionMenuItem ----
|
//---- underlineMenuSelectionMenuItem ----
|
||||||
underlineMenuSelectionMenuItem.setText("Use underline menu selection");
|
underlineMenuSelectionMenuItem.setText("Use underline menu selection");
|
||||||
underlineMenuSelectionMenuItem.addActionListener(e -> underlineMenuSelection());
|
underlineMenuSelectionMenuItem.addActionListener(e -> underlineMenuSelection());
|
||||||
@@ -877,6 +895,7 @@ class DemoFrame
|
|||||||
windowDecorationsCheckBoxMenuItem.setSelected( FlatLaf.isUseNativeWindowDecorations() );
|
windowDecorationsCheckBoxMenuItem.setSelected( FlatLaf.isUseNativeWindowDecorations() );
|
||||||
menuBarEmbeddedCheckBoxMenuItem.setSelected( UIManager.getBoolean( "TitlePane.menuBarEmbedded" ) );
|
menuBarEmbeddedCheckBoxMenuItem.setSelected( UIManager.getBoolean( "TitlePane.menuBarEmbedded" ) );
|
||||||
unifiedTitleBarMenuItem.setSelected( UIManager.getBoolean( "TitlePane.unifiedBackground" ) );
|
unifiedTitleBarMenuItem.setSelected( UIManager.getBoolean( "TitlePane.unifiedBackground" ) );
|
||||||
|
showTitleBarIconMenuItem.setSelected( UIManager.getBoolean( "TitlePane.showIcon" ) );
|
||||||
|
|
||||||
if( JBRCustomDecorations.isSupported() ) {
|
if( JBRCustomDecorations.isSupported() ) {
|
||||||
// If the JetBrains Runtime is used, it forces the use of it's own custom
|
// If the JetBrains Runtime is used, it forces the use of it's own custom
|
||||||
@@ -887,6 +906,7 @@ class DemoFrame
|
|||||||
unsupported( windowDecorationsCheckBoxMenuItem );
|
unsupported( windowDecorationsCheckBoxMenuItem );
|
||||||
unsupported( menuBarEmbeddedCheckBoxMenuItem );
|
unsupported( menuBarEmbeddedCheckBoxMenuItem );
|
||||||
unsupported( unifiedTitleBarMenuItem );
|
unsupported( unifiedTitleBarMenuItem );
|
||||||
|
unsupported( showTitleBarIconMenuItem );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( SystemInfo.isMacOS )
|
if( SystemInfo.isMacOS )
|
||||||
@@ -919,6 +939,7 @@ class DemoFrame
|
|||||||
private JCheckBoxMenuItem windowDecorationsCheckBoxMenuItem;
|
private JCheckBoxMenuItem windowDecorationsCheckBoxMenuItem;
|
||||||
private JCheckBoxMenuItem menuBarEmbeddedCheckBoxMenuItem;
|
private JCheckBoxMenuItem menuBarEmbeddedCheckBoxMenuItem;
|
||||||
private JCheckBoxMenuItem unifiedTitleBarMenuItem;
|
private JCheckBoxMenuItem unifiedTitleBarMenuItem;
|
||||||
|
private JCheckBoxMenuItem showTitleBarIconMenuItem;
|
||||||
private JCheckBoxMenuItem underlineMenuSelectionMenuItem;
|
private JCheckBoxMenuItem underlineMenuSelectionMenuItem;
|
||||||
private JCheckBoxMenuItem alwaysShowMnemonicsMenuItem;
|
private JCheckBoxMenuItem alwaysShowMnemonicsMenuItem;
|
||||||
private JCheckBoxMenuItem animatedLafChangeMenuItem;
|
private JCheckBoxMenuItem animatedLafChangeMenuItem;
|
||||||
|
|||||||
@@ -375,6 +375,14 @@ new FormModel {
|
|||||||
}
|
}
|
||||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "unifiedTitleBar", false ) )
|
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" ) {
|
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
|
||||||
name: "underlineMenuSelectionMenuItem"
|
name: "underlineMenuSelectionMenuItem"
|
||||||
"text": "Use underline menu selection"
|
"text": "Use underline menu selection"
|
||||||
|
|||||||
Reference in New Issue
Block a user