From 7c77b857f66a77b0f086af3f9d4040f4c0f69bdf Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Thu, 17 Oct 2019 12:09:22 +0200 Subject: [PATCH] SwingX: added test app --- flatlaf-core/build.gradle.kts | 13 ++++ .../com/formdev/flatlaf/FlatTestFrame.java | 2 +- flatlaf-swingx/build.gradle.kts | 1 + .../flatlaf/swingx/FlatSwingXTest.java | 72 +++++++++++++++++++ .../formdev/flatlaf/swingx/FlatSwingXTest.jfd | 39 ++++++++++ 5 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 flatlaf-swingx/src/test/java/com/formdev/flatlaf/swingx/FlatSwingXTest.java create mode 100644 flatlaf-swingx/src/test/java/com/formdev/flatlaf/swingx/FlatSwingXTest.jfd diff --git a/flatlaf-core/build.gradle.kts b/flatlaf-core/build.gradle.kts index 0b86118a..33ccf384 100644 --- a/flatlaf-core/build.gradle.kts +++ b/flatlaf-core/build.gradle.kts @@ -88,6 +88,19 @@ tasks { from( javadoc ) } + + register( "testJar", Jar::class ) { + archiveBaseName.set( "flatlaf-test" ) + from( sourceSets.test.get().output ) + } +} + +configurations { + create( "testArtifacts" ) +} + +artifacts { + add( "testArtifacts", tasks.getByPath( "testJar" ) ) } publishing { diff --git a/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatTestFrame.java b/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatTestFrame.java index 83c6752d..4b3889d9 100644 --- a/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatTestFrame.java +++ b/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatTestFrame.java @@ -204,7 +204,7 @@ public class FlatTestFrame JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ); } - protected void showFrame( JComponent content ) { + public void showFrame( JComponent content ) { this.content = content; contentPanel.getContentPane().add( content ); diff --git a/flatlaf-swingx/build.gradle.kts b/flatlaf-swingx/build.gradle.kts index f55e5716..45bd9596 100644 --- a/flatlaf-swingx/build.gradle.kts +++ b/flatlaf-swingx/build.gradle.kts @@ -24,6 +24,7 @@ dependencies { implementation( project( ":flatlaf-core" ) ) implementation( "org.swinglabs.swingx:swingx-all:1.6.5-1" ) + testImplementation( project( ":flatlaf-core", "testArtifacts" ) ) testImplementation( "org.swinglabs.swingx:swingx-beaninfo:1.6.5-1" ) testImplementation( "com.miglayout:miglayout-swing:5.2" ) } diff --git a/flatlaf-swingx/src/test/java/com/formdev/flatlaf/swingx/FlatSwingXTest.java b/flatlaf-swingx/src/test/java/com/formdev/flatlaf/swingx/FlatSwingXTest.java new file mode 100644 index 00000000..71c39ad9 --- /dev/null +++ b/flatlaf-swingx/src/test/java/com/formdev/flatlaf/swingx/FlatSwingXTest.java @@ -0,0 +1,72 @@ +/* + * 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.swingx; + +import javax.swing.*; +import net.miginfocom.swing.*; +import org.jdesktop.swingx.*; +import com.formdev.flatlaf.FlatTestFrame; + +/** + * @author Karl Tauber + */ +public class FlatSwingXTest + extends JPanel +{ + public static void main( String[] args ) { + FlatTestFrame frame = FlatTestFrame.create( args, "FlatSwingXTest" ); + frame.showFrame( new FlatSwingXTest() ); + } + + FlatSwingXTest() { + initComponents(); + } + + private void initComponents() { + // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents + JLabel hyperlinkLabel = new JLabel(); + JXHyperlink xHyperlink1 = new JXHyperlink(); + JXHyperlink xHyperlink2 = new JXHyperlink(); + + //======== this ======== + setLayout(new MigLayout( + "hidemode 3,ltr", + // columns + "[left]" + + "[]" + + "[]", + // rows + "[]")); + + //---- hyperlinkLabel ---- + hyperlinkLabel.setText("JXHyperlink:"); + add(hyperlinkLabel, "cell 0 0"); + + //---- xHyperlink1 ---- + xHyperlink1.setText("enabled"); + add(xHyperlink1, "cell 1 0"); + + //---- xHyperlink2 ---- + xHyperlink2.setText("disabled"); + xHyperlink2.setEnabled(false); + add(xHyperlink2, "cell 2 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-swingx/src/test/java/com/formdev/flatlaf/swingx/FlatSwingXTest.jfd b/flatlaf-swingx/src/test/java/com/formdev/flatlaf/swingx/FlatSwingXTest.jfd new file mode 100644 index 00000000..6e4bc03e --- /dev/null +++ b/flatlaf-swingx/src/test/java/com/formdev/flatlaf/swingx/FlatSwingXTest.jfd @@ -0,0 +1,39 @@ +JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8" + +new FormModel { + contentType: "form/swing" + root: new FormRoot { + auxiliary() { + "JavaCodeGenerator.defaultVariableLocal": true + } + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "hidemode 3,ltr" + "$columnConstraints": "[left][][]" + "$rowConstraints": "[]" + } ) { + name: "this" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "hyperlinkLabel" + "text": "JXHyperlink:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) { + name: "xHyperlink1" + "text": "enabled" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 0" + } ) + add( new FormComponent( "org.jdesktop.swingx.JXHyperlink" ) { + name: "xHyperlink2" + "text": "disabled" + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 0" + } ) + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 0 ) + "size": new java.awt.Dimension( 645, 600 ) + } ) + } +}