From 80981f7027273a6c7049112fd46ccfd56f7e6b03 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Sun, 3 May 2020 19:34:21 +0200 Subject: [PATCH] Demo: added "Extras" tab --- .../com/formdev/flatlaf/demo/DemoFrame.java | 3 + .../com/formdev/flatlaf/demo/DemoFrame.jfd | 5 + .../flatlaf/demo/extras/ExtrasPanel.java | 132 ++++++++++++++++++ .../flatlaf/demo/extras/ExtrasPanel.jfd | 63 +++++++++ .../flatlaf/demo/extras/svg/LICENSE.txt | 3 + .../demo/extras/svg/actions/colors.svg | 8 ++ .../flatlaf/demo/extras/svg/actions/copy.svg | 6 + .../demo/extras/svg/actions/execute.svg | 3 + .../demo/extras/svg/actions/intentionBulb.svg | 7 + .../extras/svg/actions/quickfixOffBulb.svg | 7 + .../demo/extras/svg/actions/suspend.svg | 3 + .../flatlaf/demo/extras/svg/errorDialog.svg | 3 + .../demo/extras/svg/informationDialog.svg | 3 + .../demo/extras/svg/objects/abstractClass.svg | 19 +++ .../extras/svg/objects/abstractMethod.svg | 19 +++ .../extras/svg/objects/annotationtype.svg | 6 + .../flatlaf/demo/extras/svg/objects/css.svg | 10 ++ .../demo/extras/svg/objects/javaScript.svg | 9 ++ .../flatlaf/demo/extras/svg/objects/xhtml.svg | 8 ++ .../flatlaf/demo/extras/svg/warningDialog.svg | 3 + .../testing/extras/FlatExtrasTest.java | 52 +++++++ .../flatlaf/testing/extras/FlatExtrasTest.jfd | 27 +++- 22 files changed, 396 insertions(+), 3 deletions(-) create mode 100644 flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/extras/ExtrasPanel.java create mode 100644 flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/extras/ExtrasPanel.jfd create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/LICENSE.txt create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/colors.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/copy.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/execute.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/intentionBulb.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/quickfixOffBulb.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/suspend.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/errorDialog.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/informationDialog.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/abstractClass.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/abstractMethod.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/annotationtype.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/css.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/javaScript.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/xhtml.svg create mode 100644 flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/warningDialog.svg diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java index 0d0329f0..b2d2939b 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java @@ -21,6 +21,7 @@ import java.awt.event.*; import javax.swing.*; import javax.swing.text.DefaultEditorKit; import com.formdev.flatlaf.FlatLaf; +import com.formdev.flatlaf.demo.extras.*; import com.formdev.flatlaf.demo.intellijthemes.*; import com.formdev.flatlaf.extras.FlatSVGIcon; import net.miginfocom.swing.*; @@ -156,6 +157,7 @@ class DemoFrame DataComponentsPanel dataComponentsPanel = new DataComponentsPanel(); TabsPanel tabsPanel = new TabsPanel(); OptionPanePanel optionPanePanel = new OptionPanePanel(); + ExtrasPanel extrasPanel1 = new ExtrasPanel(); controlBar = new ControlBar(); IJThemesPanel themesPanel = new IJThemesPanel(); @@ -447,6 +449,7 @@ class DemoFrame tabbedPane.addTab("Data Components", dataComponentsPanel); tabbedPane.addTab("SplitPane & Tabs", tabsPanel); tabbedPane.addTab("Option Pane", optionPanePanel); + tabbedPane.addTab("Extras", extrasPanel1); } contentPanel.add(tabbedPane, "cell 0 0"); } diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd index a6268309..c48c63a6 100644 --- a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd @@ -93,6 +93,11 @@ new FormModel { }, new FormLayoutConstraints( null ) { "title": "Option Pane" } ) + add( new FormComponent( "com.formdev.flatlaf.demo.extras.ExtrasPanel" ) { + name: "extrasPanel1" + }, new FormLayoutConstraints( null ) { + "title": "Extras" + } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 0" } ) diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/extras/ExtrasPanel.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/extras/ExtrasPanel.java new file mode 100644 index 00000000..b7f7426b --- /dev/null +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/extras/ExtrasPanel.java @@ -0,0 +1,132 @@ +/* + * Copyright 2020 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 + * + * https://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.demo.extras; + +import javax.swing.*; +import com.formdev.flatlaf.extras.*; +import net.miginfocom.swing.*; + +/** + * @author Karl Tauber + */ +public class ExtrasPanel + extends JPanel +{ + public ExtrasPanel() { + initComponents(); + + triStateLabel1.setText( triStateCheckBox1.getState().toString() ); + + addSVGIcon( "actions/copy.svg" ); + addSVGIcon( "actions/colors.svg" ); + addSVGIcon( "actions/execute.svg" ); + addSVGIcon( "actions/suspend.svg" ); + addSVGIcon( "actions/intentionBulb.svg" ); + addSVGIcon( "actions/quickfixOffBulb.svg" ); + + addSVGIcon( "objects/abstractClass.svg" ); + addSVGIcon( "objects/abstractMethod.svg" ); + addSVGIcon( "objects/annotationtype.svg" ); + addSVGIcon( "objects/annotationtype.svg" ); + addSVGIcon( "objects/css.svg" ); + addSVGIcon( "objects/javaScript.svg" ); + addSVGIcon( "objects/xhtml.svg" ); + + addSVGIcon( "errorDialog.svg" ); + addSVGIcon( "informationDialog.svg" ); + addSVGIcon( "warningDialog.svg" ); + } + + private void addSVGIcon( String name ) { + svgIconsPanel.add( new JLabel( new FlatSVGIcon( "com/formdev/flatlaf/demo/extras/svg/" + name ) ) ); + } + + private void triStateCheckBox1Changed() { + triStateLabel1.setText( triStateCheckBox1.getState().toString() ); + } + + private void initComponents() { + // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents + label4 = new JLabel(); + label1 = new JLabel(); + triStateCheckBox1 = new TriStateCheckBox(); + triStateLabel1 = new JLabel(); + label2 = new JLabel(); + svgIconsPanel = new JPanel(); + label3 = new JLabel(); + + //======== this ======== + setLayout(new MigLayout( + "hidemode 3", + // columns + "[]" + + "[]" + + "[left]", + // rows + "[]para" + + "[]" + + "[]" + + "[]")); + + //---- label4 ---- + label4.setText("Note: Components on this page require the flatlaf-extras library."); + add(label4, "cell 0 0 3 1"); + + //---- label1 ---- + label1.setText("TriStateCheckBox:"); + add(label1, "cell 0 1"); + + //---- triStateCheckBox1 ---- + triStateCheckBox1.setText("three states"); + triStateCheckBox1.addActionListener(e -> triStateCheckBox1Changed()); + add(triStateCheckBox1, "cell 1 1"); + + //---- triStateLabel1 ---- + triStateLabel1.setText("text"); + add(triStateLabel1, "cell 2 1"); + + //---- label2 ---- + label2.setText("SVG Icons:"); + add(label2, "cell 0 2"); + + //======== svgIconsPanel ======== + { + svgIconsPanel.setLayout(new MigLayout( + "insets 0,hidemode 3", + // columns + "[fill]", + // rows + "[grow,center]")); + } + add(svgIconsPanel, "cell 1 2 2 1"); + + //---- label3 ---- + label3.setText("The icons may change colors when switching to another theme."); + add(label3, "cell 1 3 2 1"); + // JFormDesigner - End of component initialization //GEN-END:initComponents + } + + // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables + private JLabel label4; + private JLabel label1; + private TriStateCheckBox triStateCheckBox1; + private JLabel triStateLabel1; + private JLabel label2; + private JPanel svgIconsPanel; + private JLabel label3; + // JFormDesigner - End of variables declaration //GEN-END:variables +} diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/extras/ExtrasPanel.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/extras/ExtrasPanel.jfd new file mode 100644 index 00000000..2f8faff7 --- /dev/null +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/extras/ExtrasPanel.jfd @@ -0,0 +1,63 @@ +JFDML JFormDesigner: "7.0.1.0.272" Java: "13.0.2" encoding: "UTF-8" + +new FormModel { + contentType: "form/swing" + root: new FormRoot { + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "hidemode 3" + "$columnConstraints": "[][][left]" + "$rowConstraints": "[]para[][][]" + } ) { + name: "this" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label4" + "text": "Note: Components on this page require the flatlaf-extras library." + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0 3 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label1" + "text": "TriStateCheckBox:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1" + } ) + add( new FormComponent( "com.formdev.flatlaf.extras.TriStateCheckBox" ) { + name: "triStateCheckBox1" + "text": "three states" + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "triStateCheckBox1Changed", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "triStateLabel1" + "text": "text" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label2" + "text": "SVG Icons:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 2" + } ) + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "insets 0,hidemode 3" + "$columnConstraints": "[fill]" + "$rowConstraints": "[grow,center]" + } ) { + name: "svgIconsPanel" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 2 2 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label3" + "text": "The icons may change colors when switching to another theme." + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 3 2 1" + } ) + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 0 ) + "size": new java.awt.Dimension( 500, 300 ) + } ) + } +} diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/LICENSE.txt b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/LICENSE.txt new file mode 100644 index 00000000..186cd751 --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/LICENSE.txt @@ -0,0 +1,3 @@ +The icons in this folder are from IntelliJ IDEA Community Edition, +which is licensed under the Apache 2.0 license. Copyright 2000-2019 JetBrains s.r.o. +See: https://github.com/JetBrains/intellij-community/ diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/colors.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/colors.svg new file mode 100644 index 00000000..bddfa1b6 --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/colors.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/copy.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/copy.svg new file mode 100644 index 00000000..cfbf4d6d --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/copy.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/execute.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/execute.svg new file mode 100644 index 00000000..6b05be3b --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/execute.svg @@ -0,0 +1,3 @@ + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/intentionBulb.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/intentionBulb.svg new file mode 100644 index 00000000..41566135 --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/intentionBulb.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/quickfixOffBulb.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/quickfixOffBulb.svg new file mode 100644 index 00000000..e53c922b --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/quickfixOffBulb.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/suspend.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/suspend.svg new file mode 100644 index 00000000..718f3c31 --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/actions/suspend.svg @@ -0,0 +1,3 @@ + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/errorDialog.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/errorDialog.svg new file mode 100644 index 00000000..c941d6bc --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/errorDialog.svg @@ -0,0 +1,3 @@ + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/informationDialog.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/informationDialog.svg new file mode 100644 index 00000000..599b9759 --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/informationDialog.svg @@ -0,0 +1,3 @@ + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/abstractClass.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/abstractClass.svg new file mode 100644 index 00000000..fdd31bbc --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/abstractClass.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/abstractMethod.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/abstractMethod.svg new file mode 100644 index 00000000..0ac6b954 --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/abstractMethod.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/annotationtype.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/annotationtype.svg new file mode 100644 index 00000000..ce03c7e5 --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/annotationtype.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/css.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/css.svg new file mode 100644 index 00000000..fad092bf --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/css.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/javaScript.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/javaScript.svg new file mode 100644 index 00000000..603b1d9f --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/javaScript.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/xhtml.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/xhtml.svg new file mode 100644 index 00000000..229a9660 --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/objects/xhtml.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/warningDialog.svg b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/warningDialog.svg new file mode 100644 index 00000000..ce5eb81d --- /dev/null +++ b/flatlaf-demo/src/main/resources/com/formdev/flatlaf/demo/extras/svg/warningDialog.svg @@ -0,0 +1,3 @@ + + + diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/extras/FlatExtrasTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/extras/FlatExtrasTest.java index b75b7ba6..5fca6d9b 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/extras/FlatExtrasTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/extras/FlatExtrasTest.java @@ -17,6 +17,7 @@ package com.formdev.flatlaf.testing.extras; import javax.swing.*; +import com.formdev.flatlaf.FlatIconColors; import com.formdev.flatlaf.extras.*; import com.formdev.flatlaf.testing.*; import net.miginfocom.swing.*; @@ -30,6 +31,7 @@ public class FlatExtrasTest public static void main( String[] args ) { SwingUtilities.invokeLater( () -> { FlatTestFrame frame = FlatTestFrame.create( args, "FlatExtrasTest" ); + System.out.println( UIManager.getColor( FlatIconColors.ACTIONS_GREY.key ) ); frame.showFrame( FlatExtrasTest::new ); } ); } @@ -39,6 +41,29 @@ public class FlatExtrasTest triStateLabel1.setText( triStateCheckBox1.getState().toString() ); triStateLabel2.setText( triStateCheckBox2.getState().toString() ); + + addSVGIcon( "actions/copy.svg" ); + addSVGIcon( "actions/colors.svg" ); + addSVGIcon( "actions/execute.svg" ); + addSVGIcon( "actions/suspend.svg" ); + addSVGIcon( "actions/intentionBulb.svg" ); + addSVGIcon( "actions/quickfixOffBulb.svg" ); + + addSVGIcon( "objects/abstractClass.svg" ); + addSVGIcon( "objects/abstractMethod.svg" ); + addSVGIcon( "objects/annotationtype.svg" ); + addSVGIcon( "objects/annotationtype.svg" ); + addSVGIcon( "objects/css.svg" ); + addSVGIcon( "objects/javaScript.svg" ); + addSVGIcon( "objects/xhtml.svg" ); + + addSVGIcon( "errorDialog.svg" ); + addSVGIcon( "informationDialog.svg" ); + addSVGIcon( "warningDialog.svg" ); + } + + private void addSVGIcon( String name ) { + svgIconsPanel.add( new JLabel( new FlatSVGIcon( "com/formdev/flatlaf/demo/extras/svg/" + name ) ) ); } private void triStateCheckBox1Changed() { @@ -56,6 +81,9 @@ public class FlatExtrasTest triStateLabel1 = new JLabel(); triStateCheckBox2 = new TriStateCheckBox(); triStateLabel2 = new JLabel(); + label2 = new JLabel(); + svgIconsPanel = new JPanel(); + label3 = new JLabel(); //======== this ======== setLayout(new MigLayout( @@ -66,6 +94,8 @@ public class FlatExtrasTest "[left]", // rows "[]" + + "[]" + + "[]" + "[]")); //---- label1 ---- @@ -90,6 +120,25 @@ public class FlatExtrasTest //---- triStateLabel2 ---- triStateLabel2.setText("text"); add(triStateLabel2, "cell 2 1"); + + //---- label2 ---- + label2.setText("SVG Icons:"); + add(label2, "cell 0 2"); + + //======== svgIconsPanel ======== + { + svgIconsPanel.setLayout(new MigLayout( + "insets 0,hidemode 3", + // columns + "[fill]", + // rows + "[grow,center]")); + } + add(svgIconsPanel, "cell 1 2 2 1"); + + //---- label3 ---- + label3.setText("The icons may change colors when switching to another theme."); + add(label3, "cell 1 3 2 1"); // JFormDesigner - End of component initialization //GEN-END:initComponents } @@ -99,5 +148,8 @@ public class FlatExtrasTest private JLabel triStateLabel1; private TriStateCheckBox triStateCheckBox2; private JLabel triStateLabel2; + private JLabel label2; + private JPanel svgIconsPanel; + private JLabel label3; // JFormDesigner - End of variables declaration //GEN-END:variables } diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/extras/FlatExtrasTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/extras/FlatExtrasTest.jfd index 231e5b93..18a42ed0 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/extras/FlatExtrasTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/extras/FlatExtrasTest.jfd @@ -1,4 +1,4 @@ -JFDML JFormDesigner: "7.0.0.0.194" Java: "11.0.2" encoding: "UTF-8" +JFDML JFormDesigner: "7.0.1.0.272" Java: "13.0.2" encoding: "UTF-8" new FormModel { contentType: "form/swing" @@ -6,7 +6,7 @@ new FormModel { add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "ltr,insets dialog,hidemode 3" "$columnConstraints": "[][][left]" - "$rowConstraints": "[][]" + "$rowConstraints": "[][][][]" } ) { name: "this" add( new FormComponent( "javax.swing.JLabel" ) { @@ -42,9 +42,30 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 2 1" } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label2" + "text": "SVG Icons:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 2" + } ) + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "insets 0,hidemode 3" + "$columnConstraints": "[fill]" + "$rowConstraints": "[grow,center]" + } ) { + name: "svgIconsPanel" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 2 2 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label3" + "text": "The icons may change colors when switching to another theme." + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 3 2 1" + } ) }, new FormLayoutConstraints( null ) { "location": new java.awt.Point( 0, 0 ) - "size": new java.awt.Dimension( 400, 300 ) + "size": new java.awt.Dimension( 500, 300 ) } ) } }