mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 15:07:11 -06:00
Native window decorations:
- API to check whether current platform supports window decorations `FlatLaf.supportsNativeWindowDecorations()` - API to toggle window decorations of all windows `FlatLaf.setUseNativeWindowDecorations(boolean)` - `FlatClientProperties.USE_WINDOW_DECORATIONS` can now used to toggle window decorations for single window - cleaned-up/fixed/simplified window decorations "enabled" checking: 1. if `FlatSystemProperties.USE_WINDOW_DECORATIONS` is set, its value is used 2. if `FlatClientProperties.USE_WINDOW_DECORATIONS` is set, its value is used 3. use value of UI default `TitlePane.useWindowDecorations`
This commit is contained in:
@@ -35,8 +35,8 @@ import com.formdev.flatlaf.FlatIntelliJLaf;
|
||||
import com.formdev.flatlaf.FlatLaf;
|
||||
import com.formdev.flatlaf.FlatLightLaf;
|
||||
import com.formdev.flatlaf.extras.FlatInspector;
|
||||
import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox;
|
||||
import com.formdev.flatlaf.ui.FlatLineBorder;
|
||||
import com.formdev.flatlaf.ui.FlatNativeWindowBorder;
|
||||
import com.formdev.flatlaf.util.SystemInfo;
|
||||
import net.miginfocom.swing.*;
|
||||
|
||||
@@ -304,13 +304,11 @@ public class FlatNativeWindowBorderTest
|
||||
}
|
||||
|
||||
private void nativeChanged() {
|
||||
FlatNativeWindowBorder.setHasCustomDecoration( window, nativeCheckBox.isSelected() );
|
||||
FlatLaf.setUseNativeWindowDecorations( nativeCheckBox.isSelected() );
|
||||
}
|
||||
|
||||
private void native2Changed() {
|
||||
((RootPaneContainer)window).getRootPane().putClientProperty( FlatClientProperties.USE_WINDOW_DECORATIONS, native2CheckBox.isSelected() );
|
||||
window.dispose();
|
||||
window.setVisible( true );
|
||||
((RootPaneContainer)window).getRootPane().putClientProperty( FlatClientProperties.USE_WINDOW_DECORATIONS, native2CheckBox.getChecked() );
|
||||
}
|
||||
|
||||
private void revalidateLayout() {
|
||||
@@ -382,7 +380,7 @@ public class FlatNativeWindowBorderTest
|
||||
undecoratedCheckBox = new JCheckBox();
|
||||
fullScreenCheckBox = new JCheckBox();
|
||||
nativeCheckBox = new JCheckBox();
|
||||
native2CheckBox = new JCheckBox();
|
||||
native2CheckBox = new FlatTriStateCheckBox();
|
||||
openDialogButton = new JButton();
|
||||
hideWindowButton = new JButton();
|
||||
reopenButton = new JButton();
|
||||
@@ -446,7 +444,6 @@ public class FlatNativeWindowBorderTest
|
||||
|
||||
//---- native2CheckBox ----
|
||||
native2CheckBox.setText("JRootPane.useWindowDecorations");
|
||||
native2CheckBox.setSelected(true);
|
||||
native2CheckBox.addActionListener(e -> native2Changed());
|
||||
add(native2CheckBox, "cell 0 3 3 1");
|
||||
|
||||
@@ -507,7 +504,7 @@ public class FlatNativeWindowBorderTest
|
||||
private JCheckBox undecoratedCheckBox;
|
||||
private JCheckBox fullScreenCheckBox;
|
||||
private JCheckBox nativeCheckBox;
|
||||
private JCheckBox native2CheckBox;
|
||||
private FlatTriStateCheckBox native2CheckBox;
|
||||
private JButton openDialogButton;
|
||||
private JButton hideWindowButton;
|
||||
private JButton reopenButton;
|
||||
|
||||
@@ -65,10 +65,9 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3 3 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
|
||||
name: "native2CheckBox"
|
||||
"text": "JRootPane.useWindowDecorations"
|
||||
"selected": true
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "native2Changed", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 3 3 1"
|
||||
|
||||
@@ -35,17 +35,9 @@ public class FlatWindowDecorationsTest
|
||||
{
|
||||
public static void main( String[] args ) {
|
||||
SwingUtilities.invokeLater( () -> {
|
||||
// enable custom window decoration (if LaF supports it)
|
||||
JFrame.setDefaultLookAndFeelDecorated( true );
|
||||
JDialog.setDefaultLookAndFeelDecorated( true );
|
||||
|
||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatWindowDecorationsTest" );
|
||||
frame.applyComponentOrientationToFrame = true;
|
||||
|
||||
// WARNING: Do not this in real-world programs.
|
||||
// frame.setUndecorated( true );
|
||||
// frame.getRootPane().setWindowDecorationStyle( JRootPane.FRAME );
|
||||
|
||||
Class<?> cls = FlatWindowDecorationsTest.class;
|
||||
List<Image> images = Arrays.asList(
|
||||
new ImageIcon( cls.getResource( "/com/formdev/flatlaf/testing/test16.png" ) ).getImage(),
|
||||
|
||||
Reference in New Issue
Block a user