From 1b0c2687c86a8f7678d4a5b5db44626bb69eb63e Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Thu, 24 Oct 2019 10:52:53 +0200 Subject: [PATCH] Testing: added "background" checkbox to test apps --- .../flatlaf/testing/FlatChooserTest.java | 2 +- .../flatlaf/testing/FlatChooserTest.jfd | 2 +- .../flatlaf/testing/FlatComponents2Test.java | 2 +- .../flatlaf/testing/FlatComponents2Test.jfd | 2 +- .../flatlaf/testing/FlatComponentsTest.java | 4 +- .../flatlaf/testing/FlatComponentsTest.jfd | 6 +- .../flatlaf/testing/FlatContainerTest.java | 4 +- .../flatlaf/testing/FlatContainerTest.jfd | 4 +- .../flatlaf/testing/FlatMenusTest.java | 6 +- .../formdev/flatlaf/testing/FlatMenusTest.jfd | 6 +- .../flatlaf/testing/FlatOptionPaneTest.java | 2 +- .../flatlaf/testing/FlatOptionPaneTest.jfd | 18 ++--- .../flatlaf/testing/FlatTestFrame.java | 71 ++++++++++++------- .../formdev/flatlaf/testing/FlatTestFrame.jfd | 64 +++++++++-------- .../flatlaf/testing/FlatTestPanel.java | 43 +++++++++++ .../testing/swingx/FlatSwingXTest.java | 5 +- .../flatlaf/testing/swingx/FlatSwingXTest.jfd | 4 +- 17 files changed, 165 insertions(+), 80 deletions(-) create mode 100644 flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestPanel.java diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.java index b6067576..20b031f3 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.java @@ -23,7 +23,7 @@ import net.miginfocom.swing.*; * @author Karl Tauber */ public class FlatChooserTest - extends JPanel + extends FlatTestPanel { public static void main( String[] args ) { SwingUtilities.invokeLater( () -> { diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.jfd index 192f229d..30fed7d0 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.jfd @@ -6,7 +6,7 @@ new FormModel { auxiliary() { "JavaCodeGenerator.defaultVariableLocal": true } - add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr" "$columnConstraints": "[][]" "$rowConstraints": "[top][top][]" diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.java index 6ff3da52..75c4d1f1 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.java @@ -24,7 +24,7 @@ import net.miginfocom.swing.*; * @author Karl Tauber */ public class FlatComponents2Test - extends JPanel + extends FlatTestPanel { public static void main( String[] args ) { SwingUtilities.invokeLater( () -> { diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.jfd index 21f057e6..e65436e6 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponents2Test.jfd @@ -6,7 +6,7 @@ new FormModel { auxiliary() { "JavaCodeGenerator.defaultVariableLocal": true } - add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr" "$columnConstraints": "[][200][200]" "$rowConstraints": "[][][][::200][::150]" diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java index 18f40b6d..fd8e560b 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java @@ -25,7 +25,7 @@ import net.miginfocom.swing.*; * @author Karl Tauber */ public class FlatComponentsTest - extends JPanel + extends FlatTestPanel { public static void main( String[] args ) { SwingUtilities.invokeLater( () -> { @@ -758,6 +758,7 @@ public class FlatComponentsTest //======== panel3 ======== { + panel3.setOpaque(false); panel3.setLayout(new MigLayout( "insets 0,hidemode 3,gap 5 5,ltr", // columns @@ -801,6 +802,7 @@ public class FlatComponentsTest //======== panel2 ======== { panel2.setBorder(new TitledBorder("TitledBorder")); + panel2.setOpaque(false); panel2.setLayout(new FlowLayout()); } add(panel2, "cell 3 16,grow"); diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd index c4f47980..2972c465 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd @@ -6,7 +6,7 @@ new FormModel { auxiliary() { "JavaCodeGenerator.defaultVariableLocal": true } - add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr" "$columnConstraints": "[][][][][][]" "$rowConstraints": "[][][][][][][][][][][][][][][][][][][][][][]" @@ -56,7 +56,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 2 1" } ) - add( new FormComponent( "com.formdev.flatlaf.FlatComponentsTest$TestDefaultButton" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatComponentsTest$TestDefaultButton" ) { name: "button5" "text": "default" "displayedMnemonicIndex": 0 @@ -716,6 +716,7 @@ new FormModel { "$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr" } ) { name: "panel3" + "opaque": false add( new FormComponent( "javax.swing.JLabel" ) { name: "label3" "text": "JLabel HTML
Sample content
text" @@ -759,6 +760,7 @@ new FormModel { add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.FlowLayout ) ) { name: "panel2" "border": new javax.swing.border.TitledBorder( "TitledBorder" ) + "opaque": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 3 16,grow" } ) diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.java index 57943e7f..bf2db9ef 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.java @@ -14,7 +14,7 @@ import net.miginfocom.swing.*; * @author Karl Tauber */ public class FlatContainerTest - extends JPanel + extends FlatTestPanel { public static void main( String[] args ) { SwingUtilities.invokeLater( () -> { @@ -112,6 +112,7 @@ public class FlatContainerTest //======== panel9 ======== { + panel9.setOpaque(false); panel9.setLayout(new FormLayout( "70dlu:grow, $lcgap, 70dlu:grow", "default, $lgap, fill:70dlu, $lgap, pref, 2*($lgap, fill:70dlu:grow), $lgap, pref")); @@ -283,6 +284,7 @@ public class FlatContainerTest //======== panel14 ======== { + panel14.setOpaque(false); panel14.setLayout(new MigLayout( "insets 0,hidemode 3", // columns diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.jfd index 6f5b963b..411443d9 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.jfd @@ -6,7 +6,7 @@ new FormModel { auxiliary() { "JavaCodeGenerator.defaultVariableLocal": true } - add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets 0,hidemode 3" "$columnConstraints": "[grow,fill]" "$rowConstraints": "[grow,fill]" @@ -17,6 +17,7 @@ new FormModel { "$rowSpecs": "default, linegap, fill:70dlu, linegap, pref, linegap, fill:70dlu:grow, linegap, fill:70dlu:grow, linegap, pref" } ) { name: "panel9" + "opaque": false add( new FormComponent( "javax.swing.JLabel" ) { name: "splitPaneLabel" "text": "JSplitPane:" @@ -203,6 +204,7 @@ new FormModel { "$rowConstraints": "[center]" } ) { name: "panel14" + "opaque": false add( new FormComponent( "javax.swing.JCheckBox" ) { name: "moreTabsCheckBox" "text": "more tabs" diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.java index 3ce1ed88..41f71ed9 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.java @@ -26,7 +26,7 @@ import net.miginfocom.swing.*; * @author Karl Tauber */ public class FlatMenusTest - extends JPanel + extends FlatTestPanel { public static void main( String[] args ) { SwingUtilities.invokeLater( () -> { @@ -155,6 +155,7 @@ public class FlatMenusTest //======== panel1 ======== { + panel1.setOpaque(false); panel1.setLayout(new MigLayout( "insets 0,hidemode 3,gap 5 5,ltr", // columns @@ -213,6 +214,7 @@ public class FlatMenusTest //======== panel2 ======== { + panel2.setOpaque(false); panel2.setLayout(new MigLayout( "insets 0,gap 5 5", // columns @@ -253,6 +255,7 @@ public class FlatMenusTest //======== panel3 ======== { + panel3.setOpaque(false); panel3.setLayout(new MigLayout( "insets 0,gap 5 5", // columns @@ -292,6 +295,7 @@ public class FlatMenusTest //======== panel4 ======== { + panel4.setOpaque(false); panel4.setLayout(new MigLayout( "insets 0,gap 5 5", // columns diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.jfd index 6115489a..c40b5a9b 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatMenusTest.jfd @@ -6,7 +6,7 @@ new FormModel { auxiliary() { "JavaCodeGenerator.defaultVariableLocal": true } - add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr" "$columnConstraints": "[125][][][][]" "$rowConstraints": "[][top][][]" @@ -53,6 +53,7 @@ new FormModel { "$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr" } ) { name: "panel1" + "opaque": false add( new FormComponent( "javax.swing.JLabel" ) { name: "menuLabel" "text": "JMenu:" @@ -124,6 +125,7 @@ new FormModel { "$layoutConstraints": "insets 0,gap 5 5" } ) { name: "panel2" + "opaque": false add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { name: "menu2" "text": "disabled" @@ -164,6 +166,7 @@ new FormModel { "$layoutConstraints": "insets 0,gap 5 5" } ) { name: "panel3" + "opaque": false add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { name: "menu3" "text": "text" @@ -204,6 +207,7 @@ new FormModel { "$layoutConstraints": "insets 0,gap 5 5" } ) { name: "panel4" + "opaque": false add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) { name: "menu4" "text": "text" diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.java index 63bc2cb3..e8501f16 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.java @@ -27,7 +27,7 @@ import net.miginfocom.swing.*; * @author Karl Tauber */ public class FlatOptionPaneTest - extends JPanel + extends FlatTestPanel { public static void main( String[] args ) { SwingUtilities.invokeLater( () -> { diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.jfd index 5bad3060..8c9911bf 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatOptionPaneTest.jfd @@ -6,7 +6,7 @@ new FormModel { auxiliary() { "JavaCodeGenerator.defaultVariableLocal": true } - add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "flowy,ltr,insets 0,hidemode 3,gap 5 5" "$columnConstraints": "[][][fill]" "$rowConstraints": "[top][top][top][top][top][top][top][top]" @@ -30,7 +30,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 0" } ) - add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatOptionPaneTest$ShowDialogLinkLabel" ) { name: "plainShowDialogLabel" "optionPane": new FormReference( "plainOptionPane" ) "titleLabel": new FormReference( "plainLabel" ) @@ -60,7 +60,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 1" } ) - add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatOptionPaneTest$ShowDialogLinkLabel" ) { name: "errorShowDialogLabel" "titleLabel": new FormReference( "errorLabel" ) "optionPane": new FormReference( "errorOptionPane" ) @@ -90,7 +90,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 2" } ) - add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatOptionPaneTest$ShowDialogLinkLabel" ) { name: "informationShowDialogLabel" "optionPane": new FormReference( "informationOptionPane" ) "titleLabel": new FormReference( "informationLabel" ) @@ -120,7 +120,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 3" } ) - add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatOptionPaneTest$ShowDialogLinkLabel" ) { name: "questionShowDialogLabel" "optionPane": new FormReference( "questionOptionPane" ) "titleLabel": new FormReference( "questionLabel" ) @@ -147,7 +147,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 4" } ) - add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatOptionPaneTest$ShowDialogLinkLabel" ) { name: "warningShowDialogLabel" "optionPane": new FormReference( "warningOptionPane" ) "titleLabel": new FormReference( "warningLabel" ) @@ -174,7 +174,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 5" } ) - add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatOptionPaneTest$ShowDialogLinkLabel" ) { name: "inputShowDialogLabel" "optionPane": new FormReference( "inputOptionPane" ) "titleLabel": new FormReference( "inputLabel" ) @@ -202,7 +202,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 6" } ) - add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatOptionPaneTest$ShowDialogLinkLabel" ) { name: "inputIconShowDialogLabel" "titleLabel": new FormReference( "inputIconLabel" ) "optionPane": new FormReference( "inputIconOptionPane" ) @@ -230,7 +230,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 7" } ) - add( new FormComponent( "com.formdev.flatlaf.FlatOptionPaneTest$ShowDialogLinkLabel" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatOptionPaneTest$ShowDialogLinkLabel" ) { name: "customShowDialogLabel" "optionPane": new FormReference( "customOptionPane" ) "titleLabel": new FormReference( "customLabel" ) diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java index 9ea33754..8afdff1b 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.java @@ -313,6 +313,14 @@ public class FlatTestFrame } ); } + private void backgroundChanged() { + contentPanel.repaint(); + } + + boolean isPaintBackgroundPattern() { + return backgroundCheckBox.isSelected(); + } + private void rightToLeftChanged() { ComponentOrientation orientation = rightToLeftCheckBox.isSelected() ? ComponentOrientation.RIGHT_TO_LEFT @@ -401,11 +409,12 @@ public class FlatTestFrame contentPanel = new JRootPane(); buttonBar = new JPanel(); lookAndFeelComboBox = new JComboBox<>(); - explicitColorsCheckBox = new JCheckBox(); + scaleFactorComboBox = new JComboBox<>(); rightToLeftCheckBox = new JCheckBox(); enabledCheckBox = new JCheckBox(); inspectCheckBox = new JCheckBox(); - scaleFactorComboBox = new JComboBox<>(); + explicitColorsCheckBox = new JCheckBox(); + backgroundCheckBox = new JCheckBox(); closeButton = new JButton(); //======== this ======== @@ -440,6 +449,7 @@ public class FlatTestFrame "[fill]" + "[fill]" + "[fill]" + + "[fill]" + "[grow,fill]" + "[button,fill]", // rows @@ -449,11 +459,23 @@ public class FlatTestFrame lookAndFeelComboBox.addActionListener(e -> lookAndFeelChanged()); buttonBar.add(lookAndFeelComboBox, "cell 0 0"); - //---- explicitColorsCheckBox ---- - explicitColorsCheckBox.setText("explicit colors"); - explicitColorsCheckBox.setMnemonic('X'); - explicitColorsCheckBox.addActionListener(e -> explicitColorsChanged()); - buttonBar.add(explicitColorsCheckBox, "cell 1 0"); + //---- scaleFactorComboBox ---- + scaleFactorComboBox.setModel(new DefaultComboBoxModel<>(new String[] { + "default", + "1", + "1.25", + "1.5", + "1.75", + "2.0", + "2.25", + "2.5", + "3", + "3.5", + "4" + })); + scaleFactorComboBox.setMaximumRowCount(20); + scaleFactorComboBox.addActionListener(e -> scaleFactorChanged()); + buttonBar.add(scaleFactorComboBox, "cell 1 0"); //---- rightToLeftCheckBox ---- rightToLeftCheckBox.setText("right-to-left"); @@ -474,27 +496,21 @@ public class FlatTestFrame inspectCheckBox.addActionListener(e -> inspectChanged()); buttonBar.add(inspectCheckBox, "cell 4 0"); - //---- scaleFactorComboBox ---- - scaleFactorComboBox.setModel(new DefaultComboBoxModel<>(new String[] { - "default", - "1", - "1.25", - "1.5", - "1.75", - "2.0", - "2.25", - "2.5", - "3", - "3.5", - "4" - })); - scaleFactorComboBox.setMaximumRowCount(20); - scaleFactorComboBox.addActionListener(e -> scaleFactorChanged()); - buttonBar.add(scaleFactorComboBox, "cell 5 0"); + //---- explicitColorsCheckBox ---- + explicitColorsCheckBox.setText("explicit colors"); + explicitColorsCheckBox.setMnemonic('X'); + explicitColorsCheckBox.addActionListener(e -> explicitColorsChanged()); + buttonBar.add(explicitColorsCheckBox, "cell 5 0"); + + //---- backgroundCheckBox ---- + backgroundCheckBox.setText("background"); + backgroundCheckBox.setMnemonic('B'); + backgroundCheckBox.addActionListener(e -> backgroundChanged()); + buttonBar.add(backgroundCheckBox, "cell 6 0"); //---- closeButton ---- closeButton.setText("Close"); - buttonBar.add(closeButton, "cell 7 0"); + buttonBar.add(closeButton, "cell 8 0"); } dialogPane.add(buttonBar, BorderLayout.SOUTH); } @@ -507,11 +523,12 @@ public class FlatTestFrame private JRootPane contentPanel; private JPanel buttonBar; private JComboBox lookAndFeelComboBox; - private JCheckBox explicitColorsCheckBox; + private JComboBox scaleFactorComboBox; private JCheckBox rightToLeftCheckBox; private JCheckBox enabledCheckBox; private JCheckBox inspectCheckBox; - private JComboBox scaleFactorComboBox; + private JCheckBox explicitColorsCheckBox; + private JCheckBox backgroundCheckBox; private JButton closeButton; // JFormDesigner - End of variables declaration //GEN-END:variables diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.jfd index 9ce91ad4..ca5b9b3f 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestFrame.jfd @@ -21,7 +21,7 @@ new FormModel { } ) add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets dialog" - "$columnConstraints": "[fill][fill][fill][fill][fill][fill][grow,fill][button,fill]" + "$columnConstraints": "[fill][fill][fill][fill][fill][fill][fill][grow,fill][button,fill]" "$rowSpecs": "[fill]" } ) { name: "buttonBar" @@ -34,11 +34,27 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 0" } ) - add( new FormComponent( "javax.swing.JCheckBox" ) { - name: "explicitColorsCheckBox" - "text": "explicit colors" - "mnemonic": 88 - addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "explicitColorsChanged", false ) ) + add( new FormComponent( "javax.swing.JComboBox" ) { + name: "scaleFactorComboBox" + "model": new javax.swing.DefaultComboBoxModel { + selectedItem: "default" + addElement( "default" ) + addElement( "1" ) + addElement( "1.25" ) + addElement( "1.5" ) + addElement( "1.75" ) + addElement( "2.0" ) + addElement( "2.25" ) + addElement( "2.5" ) + addElement( "3" ) + addElement( "3.5" ) + addElement( "4" ) + } + "maximumRowCount": 20 + auxiliary() { + "JavaCodeGenerator.typeParameters": "String" + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scaleFactorChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 0" } ) @@ -67,35 +83,27 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 4 0" } ) - add( new FormComponent( "javax.swing.JComboBox" ) { - name: "scaleFactorComboBox" - "model": new javax.swing.DefaultComboBoxModel { - selectedItem: "default" - addElement( "default" ) - addElement( "1" ) - addElement( "1.25" ) - addElement( "1.5" ) - addElement( "1.75" ) - addElement( "2.0" ) - addElement( "2.25" ) - addElement( "2.5" ) - addElement( "3" ) - addElement( "3.5" ) - addElement( "4" ) - } - "maximumRowCount": 20 - auxiliary() { - "JavaCodeGenerator.typeParameters": "String" - } - addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "scaleFactorChanged", false ) ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "explicitColorsCheckBox" + "text": "explicit colors" + "mnemonic": 88 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "explicitColorsChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 5 0" } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "backgroundCheckBox" + "text": "background" + "mnemonic": 66 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "backgroundChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 6 0" + } ) add( new FormComponent( "javax.swing.JButton" ) { name: "closeButton" "text": "Close" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 7 0" + "value": "cell 8 0" } ) }, new FormLayoutConstraints( class java.lang.String ) { "value": "South" diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestPanel.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestPanel.java new file mode 100644 index 00000000..a74af0e3 --- /dev/null +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestPanel.java @@ -0,0 +1,43 @@ +/* + * Copyright 2019 FormDev Software GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.formdev.flatlaf.testing; + +import java.awt.Color; +import java.awt.Graphics; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +/** + * @author Karl Tauber + */ +public class FlatTestPanel + extends JPanel +{ + @Override + protected void paintComponent( Graphics g ) { + super.paintComponent( g ); + + FlatTestFrame frame = (FlatTestFrame) SwingUtilities.getAncestorOfClass( FlatTestFrame.class, this ); + if( frame != null && frame.isPaintBackgroundPattern() ) { + g.setColor( Color.magenta ); + int width = getWidth(); + int height = getHeight(); + for( int y = 0; y < height; y += 2 ) + g.drawLine( 0, y, width - 1, y ); + } + } +} diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/swingx/FlatSwingXTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/swingx/FlatSwingXTest.java index f3d8976c..41b2ec8c 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/swingx/FlatSwingXTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/swingx/FlatSwingXTest.java @@ -23,12 +23,13 @@ import javax.swing.*; import net.miginfocom.swing.*; import org.jdesktop.swingx.*; import com.formdev.flatlaf.testing.FlatTestFrame; +import com.formdev.flatlaf.testing.FlatTestPanel; /** * @author Karl Tauber */ public class FlatSwingXTest - extends JPanel + extends FlatTestPanel { public static void main( String[] args ) { SwingUtilities.invokeLater( () -> { @@ -199,7 +200,7 @@ public class FlatSwingXTest //---- busyCheckBox ---- busyCheckBox.setText("busy"); - busyCheckBox.setMnemonic('B'); + busyCheckBox.setMnemonic('Y'); busyCheckBox.addActionListener(e -> busyChanged()); add(busyCheckBox, "cell 2 6"); diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/swingx/FlatSwingXTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/swingx/FlatSwingXTest.jfd index 54db5c33..9ce95649 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/swingx/FlatSwingXTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/swingx/FlatSwingXTest.jfd @@ -6,7 +6,7 @@ new FormModel { auxiliary() { "JavaCodeGenerator.defaultVariableLocal": true } - add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "hidemode 3,ltr" "$columnConstraints": "[left][][][fill]" "$rowConstraints": "[]0[][]0[][][][][]" @@ -144,7 +144,7 @@ new FormModel { add( new FormComponent( "javax.swing.JCheckBox" ) { name: "busyCheckBox" "text": "busy" - "mnemonic": 66 + "mnemonic": 89 auxiliary() { "JavaCodeGenerator.variableLocal": false }