mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 14:00:55 +03:00
Demo on Linux: support toggling FlatLaf window decorations (menu "Options > Window decorations")
This commit is contained in:
@@ -228,8 +228,20 @@ class DemoFrame
|
|||||||
private void windowDecorationsChanged() {
|
private void windowDecorationsChanged() {
|
||||||
boolean windowDecorations = windowDecorationsCheckBoxMenuItem.isSelected();
|
boolean windowDecorations = windowDecorationsCheckBoxMenuItem.isSelected();
|
||||||
|
|
||||||
|
if( SystemInfo.isLinux ) {
|
||||||
|
// enable/disable custom window decorations
|
||||||
|
JFrame.setDefaultLookAndFeelDecorated( windowDecorations );
|
||||||
|
JDialog.setDefaultLookAndFeelDecorated( windowDecorations );
|
||||||
|
|
||||||
|
// dispose frame, update decoration and re-show frame
|
||||||
|
dispose();
|
||||||
|
setUndecorated( windowDecorations );
|
||||||
|
getRootPane().setWindowDecorationStyle( windowDecorations ? JRootPane.FRAME : JRootPane.NONE );
|
||||||
|
setVisible( true );
|
||||||
|
} else {
|
||||||
// change window decoration of all frames and dialogs
|
// change window decoration of all frames and dialogs
|
||||||
FlatLaf.setUseNativeWindowDecorations( windowDecorations );
|
FlatLaf.setUseNativeWindowDecorations( windowDecorations );
|
||||||
|
}
|
||||||
|
|
||||||
menuBarEmbeddedCheckBoxMenuItem.setEnabled( windowDecorations );
|
menuBarEmbeddedCheckBoxMenuItem.setEnabled( windowDecorations );
|
||||||
unifiedTitleBarMenuItem.setEnabled( windowDecorations );
|
unifiedTitleBarMenuItem.setEnabled( windowDecorations );
|
||||||
@@ -486,7 +498,7 @@ class DemoFrame
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean supportsFlatLafWindowDecorations() {
|
private boolean supportsFlatLafWindowDecorations() {
|
||||||
return FlatLaf.supportsNativeWindowDecorations() || (SystemInfo.isLinux && JFrame.isDefaultLookAndFeelDecorated());
|
return FlatLaf.supportsNativeWindowDecorations() || SystemInfo.isLinux;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
@@ -979,10 +991,9 @@ class DemoFrame
|
|||||||
scrollingPopupMenu.add( "Item " + i );
|
scrollingPopupMenu.add( "Item " + i );
|
||||||
|
|
||||||
if( supportsFlatLafWindowDecorations() ) {
|
if( supportsFlatLafWindowDecorations() ) {
|
||||||
if( SystemInfo.isLinux )
|
windowDecorationsCheckBoxMenuItem.setSelected( SystemInfo.isLinux
|
||||||
unsupported( windowDecorationsCheckBoxMenuItem );
|
? JFrame.isDefaultLookAndFeelDecorated()
|
||||||
else
|
: 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" ) );
|
showTitleBarIconMenuItem.setSelected( UIManager.getBoolean( "TitlePane.showIcon" ) );
|
||||||
@@ -1026,7 +1037,7 @@ class DemoFrame
|
|||||||
private void unsupported( JCheckBoxMenuItem menuItem ) {
|
private void unsupported( JCheckBoxMenuItem menuItem ) {
|
||||||
menuItem.setEnabled( false );
|
menuItem.setEnabled( false );
|
||||||
menuItem.setSelected( false );
|
menuItem.setSelected( false );
|
||||||
menuItem.setToolTipText( "Not supported on your system." );
|
menuItem.setToolTipText( "Not supported on this platform." );
|
||||||
}
|
}
|
||||||
|
|
||||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||||
|
|||||||
Reference in New Issue
Block a user