mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 23:07:15 -06:00
Demo: use window decorations by default and added "Options > Window decorations" to menu
This commit is contained in:
@@ -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() {
|
private void menuBarEmbeddedChanged() {
|
||||||
getRootPane().putClientProperty( FlatClientProperties.MENU_BAR_EMBEDDED,
|
getRootPane().putClientProperty( FlatClientProperties.MENU_BAR_EMBEDDED,
|
||||||
menuBarEmbeddedCheckBoxMenuItem.isSelected() ? null : false );
|
menuBarEmbeddedCheckBoxMenuItem.isSelected() ? null : false );
|
||||||
@@ -231,6 +241,7 @@ class DemoFrame
|
|||||||
JMenuItem incrFontMenuItem = new JMenuItem();
|
JMenuItem incrFontMenuItem = new JMenuItem();
|
||||||
JMenuItem decrFontMenuItem = new JMenuItem();
|
JMenuItem decrFontMenuItem = new JMenuItem();
|
||||||
JMenu optionsMenu = new JMenu();
|
JMenu optionsMenu = new JMenu();
|
||||||
|
windowDecorationsCheckBoxMenuItem = new JCheckBoxMenuItem();
|
||||||
menuBarEmbeddedCheckBoxMenuItem = new JCheckBoxMenuItem();
|
menuBarEmbeddedCheckBoxMenuItem = new JCheckBoxMenuItem();
|
||||||
underlineMenuSelectionMenuItem = new JCheckBoxMenuItem();
|
underlineMenuSelectionMenuItem = new JCheckBoxMenuItem();
|
||||||
alwaysShowMnemonicsMenuItem = new JCheckBoxMenuItem();
|
alwaysShowMnemonicsMenuItem = new JCheckBoxMenuItem();
|
||||||
@@ -466,6 +477,12 @@ class DemoFrame
|
|||||||
{
|
{
|
||||||
optionsMenu.setText("Options");
|
optionsMenu.setText("Options");
|
||||||
|
|
||||||
|
//---- windowDecorationsCheckBoxMenuItem ----
|
||||||
|
windowDecorationsCheckBoxMenuItem.setText("Window decorations");
|
||||||
|
windowDecorationsCheckBoxMenuItem.setSelected(true);
|
||||||
|
windowDecorationsCheckBoxMenuItem.addActionListener(e -> windowDecorationsChanged());
|
||||||
|
optionsMenu.add(windowDecorationsCheckBoxMenuItem);
|
||||||
|
|
||||||
//---- menuBarEmbeddedCheckBoxMenuItem ----
|
//---- menuBarEmbeddedCheckBoxMenuItem ----
|
||||||
menuBarEmbeddedCheckBoxMenuItem.setText("Embedded menu bar");
|
menuBarEmbeddedCheckBoxMenuItem.setText("Embedded menu bar");
|
||||||
menuBarEmbeddedCheckBoxMenuItem.setSelected(true);
|
menuBarEmbeddedCheckBoxMenuItem.setSelected(true);
|
||||||
@@ -588,12 +605,15 @@ class DemoFrame
|
|||||||
copyMenuItem.addActionListener( new DefaultEditorKit.CopyAction() );
|
copyMenuItem.addActionListener( new DefaultEditorKit.CopyAction() );
|
||||||
pasteMenuItem.addActionListener( new DefaultEditorKit.PasteAction() );
|
pasteMenuItem.addActionListener( new DefaultEditorKit.PasteAction() );
|
||||||
|
|
||||||
menuBarEmbeddedCheckBoxMenuItem.setEnabled( UIManager.getLookAndFeel()
|
boolean supportsWindowDecorations = UIManager.getLookAndFeel()
|
||||||
.getSupportsWindowDecorations() || JBRCustomDecorations.isSupported() );
|
.getSupportsWindowDecorations() || JBRCustomDecorations.isSupported();
|
||||||
|
windowDecorationsCheckBoxMenuItem.setEnabled( supportsWindowDecorations && !JBRCustomDecorations.isSupported() );
|
||||||
|
menuBarEmbeddedCheckBoxMenuItem.setEnabled( supportsWindowDecorations );
|
||||||
}
|
}
|
||||||
|
|
||||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||||
private JMenu fontMenu;
|
private JMenu fontMenu;
|
||||||
|
private JCheckBoxMenuItem windowDecorationsCheckBoxMenuItem;
|
||||||
private JCheckBoxMenuItem menuBarEmbeddedCheckBoxMenuItem;
|
private JCheckBoxMenuItem menuBarEmbeddedCheckBoxMenuItem;
|
||||||
private JCheckBoxMenuItem underlineMenuSelectionMenuItem;
|
private JCheckBoxMenuItem underlineMenuSelectionMenuItem;
|
||||||
private JCheckBoxMenuItem alwaysShowMnemonicsMenuItem;
|
private JCheckBoxMenuItem alwaysShowMnemonicsMenuItem;
|
||||||
|
|||||||
@@ -322,6 +322,15 @@ new FormModel {
|
|||||||
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
|
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
|
||||||
name: "optionsMenu"
|
name: "optionsMenu"
|
||||||
"text": "Options"
|
"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" ) {
|
add( new FormComponent( "javax.swing.JCheckBoxMenuItem" ) {
|
||||||
name: "menuBarEmbeddedCheckBoxMenuItem"
|
name: "menuBarEmbeddedCheckBoxMenuItem"
|
||||||
"text": "Embedded menu bar"
|
"text": "Embedded menu bar"
|
||||||
|
|||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package com.formdev.flatlaf.demo;
|
package com.formdev.flatlaf.demo;
|
||||||
|
|
||||||
|
import javax.swing.JDialog;
|
||||||
|
import javax.swing.JFrame;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import com.formdev.flatlaf.extras.FlatInspector;
|
import com.formdev.flatlaf.extras.FlatInspector;
|
||||||
import com.formdev.flatlaf.util.SystemInfo;
|
import com.formdev.flatlaf.util.SystemInfo;
|
||||||
@@ -36,6 +38,10 @@ public class FlatLafDemo
|
|||||||
SwingUtilities.invokeLater( () -> {
|
SwingUtilities.invokeLater( () -> {
|
||||||
DemoPrefs.init( PREFS_ROOT_PATH );
|
DemoPrefs.init( PREFS_ROOT_PATH );
|
||||||
|
|
||||||
|
// enable window decorations
|
||||||
|
JFrame.setDefaultLookAndFeelDecorated( true );
|
||||||
|
JDialog.setDefaultLookAndFeelDecorated( true );
|
||||||
|
|
||||||
// set look and feel
|
// set look and feel
|
||||||
DemoPrefs.initLaf( args );
|
DemoPrefs.initLaf( args );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user