From 4fc890a77c5ed4d202d39879893103df5b0a962c Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sat, 10 Feb 2024 14:16:45 +0100 Subject: [PATCH] Testing: split `FlatChooserTest` into `FlatFileChooserTest` and `FlatChooserTest` --- .../flatlaf/testing/FlatColorChooserTest.java | 79 +++++++++++++++++++ .../flatlaf/testing/FlatColorChooserTest.jfd | 37 +++++++++ ...oserTest.java => FlatFileChooserTest.java} | 52 +++++------- ...hooserTest.jfd => FlatFileChooserTest.jfd} | 49 ++++-------- 4 files changed, 150 insertions(+), 67 deletions(-) create mode 100644 flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatColorChooserTest.java create mode 100644 flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatColorChooserTest.jfd rename flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/{FlatChooserTest.java => FlatFileChooserTest.java} (84%) rename flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/{FlatChooserTest.jfd => FlatFileChooserTest.jfd} (80%) diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatColorChooserTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatColorChooserTest.java new file mode 100644 index 00000000..b8913461 --- /dev/null +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatColorChooserTest.java @@ -0,0 +1,79 @@ +/* + * 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.*; +import javax.swing.*; +import javax.swing.border.*; +import net.miginfocom.swing.*; + +/** + * @author Karl Tauber + */ +public class FlatColorChooserTest + extends FlatTestPanel +{ + public static void main( String[] args ) { +// Locale.setDefault( Locale.FRENCH ); +// Locale.setDefault( Locale.GERMAN ); +// Locale.setDefault( Locale.ITALIAN ); +// Locale.setDefault( Locale.JAPANESE ); +// Locale.setDefault( Locale.SIMPLIFIED_CHINESE ); +// Locale.setDefault( Locale.TRADITIONAL_CHINESE ); + + SwingUtilities.invokeLater( () -> { + FlatTestFrame frame = FlatTestFrame.create( args, "FlatColorChooserTest" ); + frame.showFrame( FlatColorChooserTest::new ); + } ); + } + + FlatColorChooserTest() { + initComponents(); + } + + private void initComponents() { + // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents + JLabel colorChooserLabel = new JLabel(); + JPanel panel2 = new JPanel(); + JColorChooser colorChooser1 = new JColorChooser(); + + //======== this ======== + setLayout(new MigLayout( + "ltr,insets dialog,hidemode 3", + // columns + "[]" + + "[grow]", + // rows + "[top]")); + + //---- colorChooserLabel ---- + colorChooserLabel.setText("JColorChooser:"); + add(colorChooserLabel, "cell 0 0"); + + //======== panel2 ======== + { + panel2.setBorder(new MatteBorder(4, 4, 4, 4, Color.red)); + panel2.setLayout(new BorderLayout()); + panel2.add(colorChooser1, BorderLayout.CENTER); + } + add(panel2, "cell 1 0"); + // JFormDesigner - End of component initialization //GEN-END:initComponents + } + + // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables + // JFormDesigner - End of variables declaration //GEN-END:variables +} diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatColorChooserTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatColorChooserTest.jfd new file mode 100644 index 00000000..8b423a3b --- /dev/null +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatColorChooserTest.jfd @@ -0,0 +1,37 @@ +JFDML JFormDesigner: "8.2.0.0.331" Java: "21" encoding: "UTF-8" + +new FormModel { + contentType: "form/swing" + root: new FormRoot { + auxiliary() { + "JavaCodeGenerator.defaultVariableLocal": true + } + add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "ltr,insets dialog,hidemode 3" + "$columnConstraints": "[][grow]" + "$rowConstraints": "[top]" + } ) { + name: "this" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "colorChooserLabel" + "text": "JColorChooser:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) { + name: "panel2" + "border": new javax.swing.border.MatteBorder( 4, 4, 4, 4, sfield java.awt.Color red ) + add( new FormComponent( "javax.swing.JColorChooser" ) { + name: "colorChooser1" + }, new FormLayoutConstraints( class java.lang.String ) { + "value": "Center" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 0" + } ) + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 0 ) + "size": new java.awt.Dimension( 790, 790 ) + } ) + } +} diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatFileChooserTest.java similarity index 84% rename from flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.java rename to flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatFileChooserTest.java index f357b4b2..111db3b4 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatFileChooserTest.java @@ -29,7 +29,7 @@ import net.miginfocom.swing.*; /** * @author Karl Tauber */ -public class FlatChooserTest +public class FlatFileChooserTest extends FlatTestPanel { public static void main( String[] args ) { @@ -41,7 +41,7 @@ public class FlatChooserTest // Locale.setDefault( Locale.TRADITIONAL_CHINESE ); SwingUtilities.invokeLater( () -> { - FlatTestFrame frame = FlatTestFrame.create( args, "FlatChooserTest" ); + FlatTestFrame frame = FlatTestFrame.create( args, "FlatFileChooserTest" ); UIManager.put( "FileChooser.shortcuts.filesFunction", (Function) files -> { ArrayList list = new ArrayList<>( Arrays.asList( files ) ); @@ -60,11 +60,11 @@ public class FlatChooserTest return null; } ); - frame.showFrame( FlatChooserTest::new ); + frame.showFrame( FlatFileChooserTest::new ); } ); } - FlatChooserTest() { + FlatFileChooserTest() { initComponents(); } @@ -87,9 +87,6 @@ public class FlatChooserTest private void initComponents() { // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents - JLabel colorChooserLabel = new JLabel(); - JPanel panel2 = new JPanel(); - JColorChooser colorChooser1 = new JColorChooser(); JLabel fileChooserLabel = new JLabel(); JPanel panel1 = new JPanel(); fileChooser1 = new JFileChooser(); @@ -115,26 +112,13 @@ public class FlatChooserTest "[]" + "[grow]", // rows - "[top]" + "[grow,fill]" + "[]" + "[]")); - //---- colorChooserLabel ---- - colorChooserLabel.setText("JColorChooser:"); - add(colorChooserLabel, "cell 0 0"); - - //======== panel2 ======== - { - panel2.setBorder(new MatteBorder(4, 4, 4, 4, Color.red)); - panel2.setLayout(new BorderLayout()); - panel2.add(colorChooser1, BorderLayout.CENTER); - } - add(panel2, "cell 1 0"); - //---- fileChooserLabel ---- fileChooserLabel.setText("JFileChooser:"); - add(fileChooserLabel, "cell 0 1,aligny top,growy 0"); + add(fileChooserLabel, "cell 0 0,aligny top,growy 0"); //======== panel1 ======== { @@ -142,7 +126,7 @@ public class FlatChooserTest panel1.setLayout(new BorderLayout()); panel1.add(fileChooser1, BorderLayout.CENTER); } - add(panel1, "cell 1 1,growx"); + add(panel1, "cell 1 0,growx"); //======== panel3 ======== { @@ -165,51 +149,51 @@ public class FlatChooserTest showAccessoryCheckBox.addActionListener(e -> showAccessory()); panel3.add(showAccessoryCheckBox, "cell 1 0"); } - add(panel3, "cell 1 2"); + add(panel3, "cell 1 1"); //---- label1 ---- label1.setText("icons:"); - add(label1, "cell 0 3"); + add(label1, "cell 0 2"); //---- label2 ---- label2.setIcon(UIManager.getIcon("FileView.directoryIcon")); - add(label2, "cell 1 3"); + add(label2, "cell 1 2"); //---- label3 ---- label3.setIcon(UIManager.getIcon("FileView.fileIcon")); - add(label3, "cell 1 3"); + add(label3, "cell 1 2"); //---- label4 ---- label4.setIcon(UIManager.getIcon("FileView.computerIcon")); - add(label4, "cell 1 3"); + add(label4, "cell 1 2"); //---- label5 ---- label5.setIcon(UIManager.getIcon("FileView.hardDriveIcon")); - add(label5, "cell 1 3"); + add(label5, "cell 1 2"); //---- label6 ---- label6.setIcon(UIManager.getIcon("FileView.floppyDriveIcon")); - add(label6, "cell 1 3"); + add(label6, "cell 1 2"); //---- label7 ---- label7.setIcon(UIManager.getIcon("FileChooser.newFolderIcon")); - add(label7, "cell 1 3"); + add(label7, "cell 1 2"); //---- label8 ---- label8.setIcon(UIManager.getIcon("FileChooser.upFolderIcon")); - add(label8, "cell 1 3"); + add(label8, "cell 1 2"); //---- label9 ---- label9.setIcon(UIManager.getIcon("FileChooser.homeFolderIcon")); - add(label9, "cell 1 3"); + add(label9, "cell 1 2"); //---- label10 ---- label10.setIcon(UIManager.getIcon("FileChooser.detailsViewIcon")); - add(label10, "cell 1 3"); + add(label10, "cell 1 2"); //---- label11 ---- label11.setIcon(UIManager.getIcon("FileChooser.listViewIcon")); - add(label11, "cell 1 3"); + add(label11, "cell 1 2"); // JFormDesigner - End of component initialization //GEN-END:initComponents } diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatFileChooserTest.jfd similarity index 80% rename from flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.jfd rename to flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatFileChooserTest.jfd index 35aca523..50369583 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatChooserTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatFileChooserTest.jfd @@ -1,4 +1,4 @@ -JFDML JFormDesigner: "8.0.0.0.194" Java: "17.0.2" encoding: "UTF-8" +JFDML JFormDesigner: "8.2.0.0.331" Java: "21" encoding: "UTF-8" new FormModel { contentType: "form/swing" @@ -9,31 +9,14 @@ new FormModel { add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "ltr,insets dialog,hidemode 3" "$columnConstraints": "[][grow]" - "$rowConstraints": "[top][grow,fill][][]" + "$rowConstraints": "[grow,fill][][]" } ) { name: "this" - add( new FormComponent( "javax.swing.JLabel" ) { - name: "colorChooserLabel" - "text": "JColorChooser:" - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 0" - } ) - add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) { - name: "panel2" - "border": new javax.swing.border.MatteBorder( 4, 4, 4, 4, sfield java.awt.Color red ) - add( new FormComponent( "javax.swing.JColorChooser" ) { - name: "colorChooser1" - }, new FormLayoutConstraints( class java.lang.String ) { - "value": "Center" - } ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 0" - } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "fileChooserLabel" "text": "JFileChooser:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 1,aligny top,growy 0" + "value": "cell 0 0,aligny top,growy 0" } ) add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) { name: "panel1" @@ -47,7 +30,7 @@ new FormModel { "value": "Center" } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 1,growx" + "value": "cell 1 0,growx" } ) add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "hidemode 3" @@ -77,73 +60,73 @@ new FormModel { "value": "cell 1 0" } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 2" + "value": "cell 1 1" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label1" "text": "icons:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 3" + "value": "cell 0 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label2" "icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.directoryIcon" ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" + "value": "cell 1 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label3" "icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.fileIcon" ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" + "value": "cell 1 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label4" "icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.computerIcon" ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" + "value": "cell 1 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label5" "icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.hardDriveIcon" ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" + "value": "cell 1 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label6" "icon": new com.jformdesigner.model.SwingIcon( 2, "FileView.floppyDriveIcon" ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" + "value": "cell 1 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label7" "icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.newFolderIcon" ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" + "value": "cell 1 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label8" "icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.upFolderIcon" ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" + "value": "cell 1 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label9" "icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.homeFolderIcon" ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" + "value": "cell 1 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label10" "icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.detailsViewIcon" ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" + "value": "cell 1 2" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "label11" "icon": new com.jformdesigner.model.SwingIcon( 2, "FileChooser.listViewIcon" ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 3" + "value": "cell 1 2" } ) }, new FormLayoutConstraints( null ) { "location": new java.awt.Point( 0, 0 )