mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-11 22:47:13 -06:00
Merge PR #429: Window title bar improvements (Windows 10/11 only)
This commit is contained in:
@@ -33,6 +33,7 @@ public class FlatOptionPaneTest
|
||||
public static void main( String[] args ) {
|
||||
SwingUtilities.invokeLater( () -> {
|
||||
FlatTestFrame frame = FlatTestFrame.create( args, "FlatOptionPaneTest" );
|
||||
frame.setIconImage( new ImageIcon( FlatOptionPaneTest.class.getResource( "/com/formdev/flatlaf/testing/test16.png" ) ).getImage() );
|
||||
frame.showFrame( FlatOptionPaneTest::new );
|
||||
} );
|
||||
}
|
||||
@@ -54,6 +55,10 @@ public class FlatOptionPaneTest
|
||||
} );
|
||||
}
|
||||
|
||||
private void showTitleBarIcon() {
|
||||
UIManager.put( "OptionPane.showIcon", showTitleBarIconCheckBox.isSelected() );
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
|
||||
ScrollablePanel panel9 = new ScrollablePanel();
|
||||
@@ -61,6 +66,7 @@ public class FlatOptionPaneTest
|
||||
JPanel panel1 = new JPanel();
|
||||
JOptionPane plainOptionPane = new JOptionPane();
|
||||
plainShowDialogLabel = new FlatOptionPaneTest.ShowDialogLinkLabel();
|
||||
showTitleBarIconCheckBox = new JCheckBox();
|
||||
JLabel errorLabel = new JLabel();
|
||||
JPanel panel2 = new JPanel();
|
||||
JOptionPane errorOptionPane = new JOptionPane();
|
||||
@@ -100,7 +106,7 @@ public class FlatOptionPaneTest
|
||||
//======== panel9 ========
|
||||
{
|
||||
panel9.setLayout(new MigLayout(
|
||||
"flowy,ltr,insets dialog,hidemode 3",
|
||||
"ltr,insets dialog,hidemode 3",
|
||||
// columns
|
||||
"[]" +
|
||||
"[]" +
|
||||
@@ -134,7 +140,12 @@ public class FlatOptionPaneTest
|
||||
//---- plainShowDialogLabel ----
|
||||
plainShowDialogLabel.setOptionPane(plainOptionPane);
|
||||
plainShowDialogLabel.setTitleLabel(plainLabel);
|
||||
panel9.add(plainShowDialogLabel, "cell 2 0");
|
||||
panel9.add(plainShowDialogLabel, "cell 1 0");
|
||||
|
||||
//---- showTitleBarIconCheckBox ----
|
||||
showTitleBarIconCheckBox.setText("Show window title bar icon");
|
||||
showTitleBarIconCheckBox.addActionListener(e -> showTitleBarIcon());
|
||||
panel9.add(showTitleBarIconCheckBox, "cell 2 0");
|
||||
|
||||
//---- errorLabel ----
|
||||
errorLabel.setText("Error");
|
||||
@@ -156,7 +167,7 @@ public class FlatOptionPaneTest
|
||||
//---- errorShowDialogLabel ----
|
||||
errorShowDialogLabel.setTitleLabel(errorLabel);
|
||||
errorShowDialogLabel.setOptionPane(errorOptionPane);
|
||||
panel9.add(errorShowDialogLabel, "cell 2 1");
|
||||
panel9.add(errorShowDialogLabel, "cell 1 1");
|
||||
|
||||
//---- informationLabel ----
|
||||
informationLabel.setText("Information");
|
||||
@@ -178,7 +189,7 @@ public class FlatOptionPaneTest
|
||||
//---- informationShowDialogLabel ----
|
||||
informationShowDialogLabel.setOptionPane(informationOptionPane);
|
||||
informationShowDialogLabel.setTitleLabel(informationLabel);
|
||||
panel9.add(informationShowDialogLabel, "cell 2 2");
|
||||
panel9.add(informationShowDialogLabel, "cell 1 2");
|
||||
|
||||
//---- questionLabel ----
|
||||
questionLabel.setText("Question");
|
||||
@@ -222,7 +233,7 @@ public class FlatOptionPaneTest
|
||||
//---- warningShowDialogLabel ----
|
||||
warningShowDialogLabel.setOptionPane(warningOptionPane);
|
||||
warningShowDialogLabel.setTitleLabel(warningLabel);
|
||||
panel9.add(warningShowDialogLabel, "cell 2 4");
|
||||
panel9.add(warningShowDialogLabel, "cell 1 4");
|
||||
|
||||
//---- inputLabel ----
|
||||
inputLabel.setText("Input");
|
||||
@@ -244,7 +255,7 @@ public class FlatOptionPaneTest
|
||||
//---- inputShowDialogLabel ----
|
||||
inputShowDialogLabel.setOptionPane(inputOptionPane);
|
||||
inputShowDialogLabel.setTitleLabel(inputLabel);
|
||||
panel9.add(inputShowDialogLabel, "cell 2 5");
|
||||
panel9.add(inputShowDialogLabel, "cell 1 5");
|
||||
|
||||
//---- inputIconLabel ----
|
||||
inputIconLabel.setText("Input + icon");
|
||||
@@ -267,7 +278,7 @@ public class FlatOptionPaneTest
|
||||
//---- inputIconShowDialogLabel ----
|
||||
inputIconShowDialogLabel.setTitleLabel(inputIconLabel);
|
||||
inputIconShowDialogLabel.setOptionPane(inputIconOptionPane);
|
||||
panel9.add(inputIconShowDialogLabel, "cell 2 6");
|
||||
panel9.add(inputIconShowDialogLabel, "cell 1 6");
|
||||
|
||||
//---- customLabel ----
|
||||
customLabel.setText("Custom");
|
||||
@@ -287,7 +298,7 @@ public class FlatOptionPaneTest
|
||||
//---- customShowDialogLabel ----
|
||||
customShowDialogLabel.setOptionPane(customOptionPane);
|
||||
customShowDialogLabel.setTitleLabel(customLabel);
|
||||
panel9.add(customShowDialogLabel, "cell 2 7");
|
||||
panel9.add(customShowDialogLabel, "cell 1 7");
|
||||
|
||||
//---- rightToLeftLabel ----
|
||||
rightToLeftLabel.setText("Right-to-left:");
|
||||
@@ -317,6 +328,7 @@ public class FlatOptionPaneTest
|
||||
|
||||
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
|
||||
private FlatOptionPaneTest.ShowDialogLinkLabel plainShowDialogLabel;
|
||||
private JCheckBox showTitleBarIconCheckBox;
|
||||
private FlatOptionPaneTest.ShowDialogLinkLabel errorShowDialogLabel;
|
||||
private FlatOptionPaneTest.ShowDialogLinkLabel informationShowDialogLabel;
|
||||
private JOptionPane customOptionPane;
|
||||
@@ -333,6 +345,7 @@ public class FlatOptionPaneTest
|
||||
|
||||
ShowDialogLinkLabel() {
|
||||
setText( "<html><a href=\"#\">Show dialog</a></html>" );
|
||||
setCursor( Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) );
|
||||
|
||||
addMouseListener( new MouseAdapter() {
|
||||
@Override
|
||||
|
||||
@@ -10,7 +10,7 @@ new FormModel {
|
||||
name: "this"
|
||||
"border": new javax.swing.border.EmptyBorder( 0, 0, 0, 0 )
|
||||
add( new FormContainer( "com.formdev.flatlaf.demo.ScrollablePanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$layoutConstraints": "flowy,ltr,insets dialog,hidemode 3"
|
||||
"$layoutConstraints": "ltr,insets dialog,hidemode 3"
|
||||
"$columnConstraints": "[][][fill]"
|
||||
"$rowConstraints": "[top][top][top][top][top][top][top][top][top]"
|
||||
} ) {
|
||||
@@ -40,6 +40,16 @@ new FormModel {
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 0"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JCheckBox" ) {
|
||||
name: "showTitleBarIconCheckBox"
|
||||
"text": "Show window title bar icon"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showTitleBarIcon", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 0"
|
||||
} )
|
||||
@@ -71,7 +81,7 @@ new FormModel {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 1"
|
||||
"value": "cell 1 1"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "informationLabel"
|
||||
@@ -101,7 +111,7 @@ new FormModel {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 2"
|
||||
"value": "cell 1 2"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "questionLabel"
|
||||
@@ -155,7 +165,7 @@ new FormModel {
|
||||
"optionPane": new FormReference( "warningOptionPane" )
|
||||
"titleLabel": new FormReference( "warningLabel" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 4"
|
||||
"value": "cell 1 4"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "inputLabel"
|
||||
@@ -182,7 +192,7 @@ new FormModel {
|
||||
"optionPane": new FormReference( "inputOptionPane" )
|
||||
"titleLabel": new FormReference( "inputLabel" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 5"
|
||||
"value": "cell 1 5"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "inputIconLabel"
|
||||
@@ -210,7 +220,7 @@ new FormModel {
|
||||
"titleLabel": new FormReference( "inputIconLabel" )
|
||||
"optionPane": new FormReference( "inputIconOptionPane" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 6"
|
||||
"value": "cell 1 6"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "customLabel"
|
||||
@@ -238,7 +248,7 @@ new FormModel {
|
||||
"optionPane": new FormReference( "customOptionPane" )
|
||||
"titleLabel": new FormReference( "customLabel" )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 2 7"
|
||||
"value": "cell 1 7"
|
||||
} )
|
||||
add( new FormComponent( "javax.swing.JLabel" ) {
|
||||
name: "rightToLeftLabel"
|
||||
@@ -273,7 +283,7 @@ new FormModel {
|
||||
} )
|
||||
}, new FormLayoutConstraints( null ) {
|
||||
"location": new java.awt.Point( 0, 0 )
|
||||
"size": new java.awt.Dimension( 895, 1080 )
|
||||
"size": new java.awt.Dimension( 995, 1080 )
|
||||
} )
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import javax.swing.*;
|
||||
import com.formdev.flatlaf.FlatClientProperties;
|
||||
import com.formdev.flatlaf.extras.components.FlatTriStateCheckBox;
|
||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||
import com.formdev.flatlaf.util.MultiResolutionImageSupport;
|
||||
import net.miginfocom.swing.*;
|
||||
@@ -73,6 +74,9 @@ public class FlatWindowDecorationsTest
|
||||
menuBarCheckBox.setSelected( window instanceof JFrame );
|
||||
maximizedBoundsCheckBox.setEnabled( window instanceof Frame );
|
||||
|
||||
menuBarEmbeddedCheckBox.setSelected( UIManager.getBoolean( "TitlePane.menuBarEmbedded" ) );
|
||||
unifiedBackgroundCheckBox.setSelected( UIManager.getBoolean( "TitlePane.unifiedBackground" ) );
|
||||
|
||||
addMenuButton.setEnabled( menuBarCheckBox.isEnabled() );
|
||||
addGlueButton.setEnabled( menuBarCheckBox.isEnabled() );
|
||||
removeMenuButton.setEnabled( menuBarCheckBox.isEnabled() );
|
||||
@@ -402,6 +406,12 @@ public class FlatWindowDecorationsTest
|
||||
}
|
||||
}
|
||||
|
||||
private void showIconChanged() {
|
||||
JRootPane rootPane = getWindowRootPane();
|
||||
if( rootPane != null )
|
||||
rootPane.putClientProperty( FlatClientProperties.TITLE_BAR_SHOW_ICON, showIconCheckBox.getChecked() );
|
||||
}
|
||||
|
||||
private JRootPane getWindowRootPane() {
|
||||
Window window = SwingUtilities.windowForComponent( this );
|
||||
if( window instanceof JFrame )
|
||||
@@ -450,6 +460,7 @@ public class FlatWindowDecorationsTest
|
||||
iconTestRandomRadioButton = new JRadioButton();
|
||||
iconTestMRIRadioButton = new JRadioButton();
|
||||
iconTestDynMRIRadioButton = new JRadioButton();
|
||||
showIconCheckBox = new FlatTriStateCheckBox();
|
||||
JButton openDialogButton = new JButton();
|
||||
JButton openFrameButton = new JButton();
|
||||
menuBar = new JMenuBar();
|
||||
@@ -685,12 +696,13 @@ public class FlatWindowDecorationsTest
|
||||
panel2.setLayout(new MigLayout(
|
||||
"ltr,insets 0,hidemode 3,gap 0 0",
|
||||
// columns
|
||||
"[fill]",
|
||||
"[left]",
|
||||
// rows
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]" +
|
||||
"[]rel" +
|
||||
"[]"));
|
||||
|
||||
//---- iconNoneRadioButton ----
|
||||
@@ -718,6 +730,11 @@ public class FlatWindowDecorationsTest
|
||||
iconTestDynMRIRadioButton.setText("test dynamic multi-resolution (Java 9+)");
|
||||
iconTestDynMRIRadioButton.addActionListener(e -> iconChanged());
|
||||
panel2.add(iconTestDynMRIRadioButton, "cell 0 4");
|
||||
|
||||
//---- showIconCheckBox ----
|
||||
showIconCheckBox.setText("show icon");
|
||||
showIconCheckBox.addActionListener(e -> showIconChanged());
|
||||
panel2.add(showIconCheckBox, "cell 0 5");
|
||||
}
|
||||
add(panel2, "cell 1 8");
|
||||
|
||||
@@ -955,6 +972,7 @@ public class FlatWindowDecorationsTest
|
||||
private JRadioButton iconTestRandomRadioButton;
|
||||
private JRadioButton iconTestMRIRadioButton;
|
||||
private JRadioButton iconTestDynMRIRadioButton;
|
||||
private FlatTriStateCheckBox showIconCheckBox;
|
||||
private JMenuBar menuBar;
|
||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||
}
|
||||
|
||||
@@ -327,8 +327,8 @@ new FormModel {
|
||||
"value": "cell 0 8"
|
||||
} )
|
||||
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) {
|
||||
"$columnConstraints": "[fill]"
|
||||
"$rowConstraints": "[][][][][]"
|
||||
"$columnConstraints": "[left]"
|
||||
"$rowConstraints": "[][][][][]rel[]"
|
||||
"$layoutConstraints": "ltr,insets 0,hidemode 3,gap 0 0"
|
||||
} ) {
|
||||
name: "panel2"
|
||||
@@ -388,6 +388,16 @@ new FormModel {
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 4"
|
||||
} )
|
||||
add( new FormComponent( "com.formdev.flatlaf.extras.components.FlatTriStateCheckBox" ) {
|
||||
name: "showIconCheckBox"
|
||||
"text": "show icon"
|
||||
auxiliary() {
|
||||
"JavaCodeGenerator.variableLocal": false
|
||||
}
|
||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showIconChanged", false ) )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 0 5"
|
||||
} )
|
||||
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {
|
||||
"value": "cell 1 8"
|
||||
} )
|
||||
|
||||
Reference in New Issue
Block a user