Demo: added "Extras" tab

This commit is contained in:
Karl Tauber
2020-05-03 19:34:21 +02:00
parent 8e6e971b51
commit 80981f7027
22 changed files with 396 additions and 3 deletions

View File

@@ -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");
}

View File

@@ -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"
} )

View File

@@ -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
}

View File

@@ -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 )
} )
}
}