diff --git a/flatlaf-demo/build.gradle.kts b/flatlaf-demo/build.gradle.kts new file mode 100644 index 00000000..58771930 --- /dev/null +++ b/flatlaf-demo/build.gradle.kts @@ -0,0 +1,35 @@ +/* + * 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. + */ + +version = rootProject.version + +plugins { + `java-library` +} + +repositories { + jcenter() +} + +dependencies { + implementation( project( ":flatlaf-core" ) ) + implementation( "com.miglayout:miglayout-swing:5.2" ) +} + +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.java new file mode 100644 index 00000000..8280ef6c --- /dev/null +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.java @@ -0,0 +1,542 @@ +/* + * 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.demo; + +import javax.swing.*; +import net.miginfocom.swing.*; + +/** + * @author Karl Tauber + */ +class BasicComponentsPanel + extends JPanel +{ + BasicComponentsPanel() { + initComponents(); + } + + private void initComponents() { + // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents + JLabel labelLabel = new JLabel(); + JLabel label1 = new JLabel(); + JLabel label2 = new JLabel(); + JLabel buttonLabel = new JLabel(); + JButton button1 = new JButton(); + JButton button2 = new JButton(); + JLabel toggleButtonLabel = new JLabel(); + JToggleButton toggleButton1 = new JToggleButton(); + JToggleButton toggleButton2 = new JToggleButton(); + JToggleButton toggleButton3 = new JToggleButton(); + JToggleButton toggleButton4 = new JToggleButton(); + JLabel checkBoxLabel = new JLabel(); + JCheckBox checkBox1 = new JCheckBox(); + JCheckBox checkBox2 = new JCheckBox(); + JCheckBox checkBox3 = new JCheckBox(); + JCheckBox checkBox4 = new JCheckBox(); + JLabel radioButtonLabel = new JLabel(); + JRadioButton radioButton1 = new JRadioButton(); + JRadioButton radioButton2 = new JRadioButton(); + JRadioButton radioButton3 = new JRadioButton(); + JRadioButton radioButton4 = new JRadioButton(); + JLabel comboBoxLabel = new JLabel(); + JComboBox comboBox1 = new JComboBox<>(); + JComboBox comboBox2 = new JComboBox<>(); + JComboBox comboBox3 = new JComboBox<>(); + JComboBox comboBox4 = new JComboBox<>(); + JLabel spinnerLabel = new JLabel(); + JSpinner spinner1 = new JSpinner(); + JSpinner spinner2 = new JSpinner(); + JLabel textFieldLabel = new JLabel(); + JTextField textField1 = new JTextField(); + JTextField textField2 = new JTextField(); + JTextField textField3 = new JTextField(); + JTextField textField4 = new JTextField(); + JLabel formattedTextFieldLabel = new JLabel(); + JFormattedTextField formattedTextField1 = new JFormattedTextField(); + JFormattedTextField formattedTextField2 = new JFormattedTextField(); + JFormattedTextField formattedTextField3 = new JFormattedTextField(); + JFormattedTextField formattedTextField4 = new JFormattedTextField(); + JLabel passwordFieldLabel = new JLabel(); + JPasswordField passwordField1 = new JPasswordField(); + JPasswordField passwordField2 = new JPasswordField(); + JPasswordField passwordField3 = new JPasswordField(); + JPasswordField passwordField4 = new JPasswordField(); + JLabel textAreaLabel = new JLabel(); + JScrollPane scrollPane1 = new JScrollPane(); + JTextArea textArea1 = new JTextArea(); + JScrollPane scrollPane2 = new JScrollPane(); + JTextArea textArea2 = new JTextArea(); + JScrollPane scrollPane3 = new JScrollPane(); + JTextArea textArea3 = new JTextArea(); + JScrollPane scrollPane4 = new JScrollPane(); + JTextArea textArea4 = new JTextArea(); + JTextArea textArea5 = new JTextArea(); + JLabel editorPaneLabel = new JLabel(); + JScrollPane scrollPane5 = new JScrollPane(); + JEditorPane editorPane1 = new JEditorPane(); + JScrollPane scrollPane6 = new JScrollPane(); + JEditorPane editorPane2 = new JEditorPane(); + JScrollPane scrollPane7 = new JScrollPane(); + JEditorPane editorPane3 = new JEditorPane(); + JScrollPane scrollPane8 = new JScrollPane(); + JEditorPane editorPane4 = new JEditorPane(); + JEditorPane editorPane5 = new JEditorPane(); + JLabel textPaneLabel = new JLabel(); + JScrollPane scrollPane9 = new JScrollPane(); + JTextPane textPane1 = new JTextPane(); + JScrollPane scrollPane10 = new JScrollPane(); + JTextPane textPane2 = new JTextPane(); + JScrollPane scrollPane11 = new JScrollPane(); + JTextPane textPane3 = new JTextPane(); + JScrollPane scrollPane12 = new JScrollPane(); + JTextPane textPane4 = new JTextPane(); + JTextPane textPane5 = new JTextPane(); + + //======== this ======== + setLayout(new MigLayout( + "ltr,hidemode 3", + // columns + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]", + // rows + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]")); + + //---- labelLabel ---- + labelLabel.setText("JLabel:"); + add(labelLabel, "cell 0 0"); + + //---- label1 ---- + label1.setText("enabled"); + label1.setDisplayedMnemonic('E'); + add(label1, "cell 1 0"); + + //---- label2 ---- + label2.setText("disabled"); + label2.setDisplayedMnemonic('D'); + label2.setEnabled(false); + add(label2, "cell 2 0"); + + //---- buttonLabel ---- + buttonLabel.setText("JButton:"); + add(buttonLabel, "cell 0 1"); + + //---- button1 ---- + button1.setText("enabled"); + button1.setDisplayedMnemonicIndex(0); + add(button1, "cell 1 1"); + + //---- button2 ---- + button2.setText("disabled"); + button2.setDisplayedMnemonicIndex(0); + button2.setEnabled(false); + add(button2, "cell 2 1"); + + //---- toggleButtonLabel ---- + toggleButtonLabel.setText("JToggleButton:"); + add(toggleButtonLabel, "cell 0 2"); + + //---- toggleButton1 ---- + toggleButton1.setText("enabled"); + add(toggleButton1, "cell 1 2"); + + //---- toggleButton2 ---- + toggleButton2.setText("disabled"); + toggleButton2.setEnabled(false); + add(toggleButton2, "cell 2 2"); + + //---- toggleButton3 ---- + toggleButton3.setText("selected"); + toggleButton3.setSelected(true); + add(toggleButton3, "cell 3 2"); + + //---- toggleButton4 ---- + toggleButton4.setText("selected disabled"); + toggleButton4.setEnabled(false); + toggleButton4.setSelected(true); + add(toggleButton4, "cell 4 2"); + + //---- checkBoxLabel ---- + checkBoxLabel.setText("JCheckBox"); + add(checkBoxLabel, "cell 0 3"); + + //---- checkBox1 ---- + checkBox1.setText("enabled"); + checkBox1.setMnemonic('A'); + add(checkBox1, "cell 1 3"); + + //---- checkBox2 ---- + checkBox2.setText("disabled"); + checkBox2.setEnabled(false); + checkBox2.setMnemonic('D'); + add(checkBox2, "cell 2 3"); + + //---- checkBox3 ---- + checkBox3.setText("selected"); + checkBox3.setSelected(true); + add(checkBox3, "cell 3 3"); + + //---- checkBox4 ---- + checkBox4.setText("selected disabled"); + checkBox4.setSelected(true); + checkBox4.setEnabled(false); + add(checkBox4, "cell 4 3"); + + //---- radioButtonLabel ---- + radioButtonLabel.setText("JRadioButton:"); + add(radioButtonLabel, "cell 0 4"); + + //---- radioButton1 ---- + radioButton1.setText("enabled"); + radioButton1.setMnemonic('N'); + add(radioButton1, "cell 1 4"); + + //---- radioButton2 ---- + radioButton2.setText("disabled"); + radioButton2.setEnabled(false); + radioButton2.setMnemonic('S'); + add(radioButton2, "cell 2 4"); + + //---- radioButton3 ---- + radioButton3.setText("selected"); + radioButton3.setSelected(true); + add(radioButton3, "cell 3 4"); + + //---- radioButton4 ---- + radioButton4.setText("selected disabled"); + radioButton4.setSelected(true); + radioButton4.setEnabled(false); + add(radioButton4, "cell 4 4"); + + //---- comboBoxLabel ---- + comboBoxLabel.setText("JComboBox:"); + add(comboBoxLabel, "cell 0 5"); + + //---- comboBox1 ---- + comboBox1.setEditable(true); + comboBox1.setModel(new DefaultComboBoxModel<>(new String[] { + "editable", + "a", + "bb", + "ccc" + })); + add(comboBox1, "cell 1 5,growx"); + + //---- comboBox2 ---- + comboBox2.setEditable(true); + comboBox2.setEnabled(false); + comboBox2.setModel(new DefaultComboBoxModel<>(new String[] { + "disabled", + "a", + "bb", + "ccc" + })); + add(comboBox2, "cell 2 5,growx"); + + //---- comboBox3 ---- + comboBox3.setModel(new DefaultComboBoxModel<>(new String[] { + "not editable", + "a", + "bb", + "ccc" + })); + add(comboBox3, "cell 3 5,growx"); + + //---- comboBox4 ---- + comboBox4.setModel(new DefaultComboBoxModel<>(new String[] { + "not editable disabled", + "a", + "bb", + "ccc" + })); + comboBox4.setEnabled(false); + add(comboBox4, "cell 4 5,growx"); + + //---- spinnerLabel ---- + spinnerLabel.setText("JSpinner:"); + add(spinnerLabel, "cell 0 6"); + add(spinner1, "cell 1 6,growx"); + + //---- spinner2 ---- + spinner2.setEnabled(false); + add(spinner2, "cell 2 6,growx"); + + //---- textFieldLabel ---- + textFieldLabel.setText("JTextField:"); + add(textFieldLabel, "cell 0 7"); + + //---- textField1 ---- + textField1.setText("editable"); + add(textField1, "cell 1 7,growx"); + + //---- textField2 ---- + textField2.setText("disabled"); + textField2.setEnabled(false); + add(textField2, "cell 2 7,growx"); + + //---- textField3 ---- + textField3.setText("not editable"); + textField3.setEditable(false); + add(textField3, "cell 3 7,growx"); + + //---- textField4 ---- + textField4.setText("not editable disabled"); + textField4.setEnabled(false); + textField4.setEditable(false); + add(textField4, "cell 4 7,growx"); + + //---- formattedTextFieldLabel ---- + formattedTextFieldLabel.setText("JFormattedTextField:"); + add(formattedTextFieldLabel, "cell 0 8"); + + //---- formattedTextField1 ---- + formattedTextField1.setText("editable"); + add(formattedTextField1, "cell 1 8,growx"); + + //---- formattedTextField2 ---- + formattedTextField2.setText("disabled"); + formattedTextField2.setEnabled(false); + add(formattedTextField2, "cell 2 8,growx"); + + //---- formattedTextField3 ---- + formattedTextField3.setText("not editable"); + formattedTextField3.setEditable(false); + add(formattedTextField3, "cell 3 8,growx"); + + //---- formattedTextField4 ---- + formattedTextField4.setText("not editable disabled"); + formattedTextField4.setEnabled(false); + formattedTextField4.setEditable(false); + add(formattedTextField4, "cell 4 8,growx"); + + //---- passwordFieldLabel ---- + passwordFieldLabel.setText("JPasswordField:"); + add(passwordFieldLabel, "cell 0 9"); + + //---- passwordField1 ---- + passwordField1.setText("editable"); + add(passwordField1, "cell 1 9,growx"); + + //---- passwordField2 ---- + passwordField2.setText("disabled"); + passwordField2.setEnabled(false); + add(passwordField2, "cell 2 9,growx"); + + //---- passwordField3 ---- + passwordField3.setText("not editable"); + passwordField3.setEditable(false); + add(passwordField3, "cell 3 9,growx"); + + //---- passwordField4 ---- + passwordField4.setText("not editable disabled"); + passwordField4.setEnabled(false); + passwordField4.setEditable(false); + add(passwordField4, "cell 4 9,growx"); + + //---- textAreaLabel ---- + textAreaLabel.setText("JTextArea:"); + add(textAreaLabel, "cell 0 10"); + + //======== scrollPane1 ======== + { + scrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- textArea1 ---- + textArea1.setText("editable"); + textArea1.setRows(2); + scrollPane1.setViewportView(textArea1); + } + add(scrollPane1, "cell 1 10,growx"); + + //======== scrollPane2 ======== + { + scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- textArea2 ---- + textArea2.setText("disabled"); + textArea2.setRows(2); + textArea2.setEnabled(false); + scrollPane2.setViewportView(textArea2); + } + add(scrollPane2, "cell 2 10,growx"); + + //======== scrollPane3 ======== + { + scrollPane3.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane3.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- textArea3 ---- + textArea3.setText("not editable"); + textArea3.setRows(2); + textArea3.setEditable(false); + scrollPane3.setViewportView(textArea3); + } + add(scrollPane3, "cell 3 10,growx"); + + //======== scrollPane4 ======== + { + scrollPane4.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane4.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- textArea4 ---- + textArea4.setText("not editable disabled"); + textArea4.setRows(2); + textArea4.setEditable(false); + textArea4.setEnabled(false); + scrollPane4.setViewportView(textArea4); + } + add(scrollPane4, "cell 4 10,growx"); + + //---- textArea5 ---- + textArea5.setRows(2); + textArea5.setText("no scroll pane"); + add(textArea5, "cell 5 10,growx"); + + //---- editorPaneLabel ---- + editorPaneLabel.setText("JEditorPane"); + add(editorPaneLabel, "cell 0 11"); + + //======== scrollPane5 ======== + { + scrollPane5.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane5.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- editorPane1 ---- + editorPane1.setText("editable"); + scrollPane5.setViewportView(editorPane1); + } + add(scrollPane5, "cell 1 11,growx"); + + //======== scrollPane6 ======== + { + scrollPane6.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane6.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- editorPane2 ---- + editorPane2.setText("disabled"); + editorPane2.setEnabled(false); + scrollPane6.setViewportView(editorPane2); + } + add(scrollPane6, "cell 2 11,growx"); + + //======== scrollPane7 ======== + { + scrollPane7.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane7.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- editorPane3 ---- + editorPane3.setText("not editable"); + editorPane3.setEditable(false); + scrollPane7.setViewportView(editorPane3); + } + add(scrollPane7, "cell 3 11,growx"); + + //======== scrollPane8 ======== + { + scrollPane8.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane8.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- editorPane4 ---- + editorPane4.setText("not editable disabled"); + editorPane4.setEditable(false); + editorPane4.setEnabled(false); + scrollPane8.setViewportView(editorPane4); + } + add(scrollPane8, "cell 4 11,growx"); + + //---- editorPane5 ---- + editorPane5.setText("no scroll pane"); + add(editorPane5, "cell 5 11,growx"); + + //---- textPaneLabel ---- + textPaneLabel.setText("JTextPane:"); + add(textPaneLabel, "cell 0 12"); + + //======== scrollPane9 ======== + { + scrollPane9.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane9.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- textPane1 ---- + textPane1.setText("editable"); + scrollPane9.setViewportView(textPane1); + } + add(scrollPane9, "cell 1 12,growx"); + + //======== scrollPane10 ======== + { + scrollPane10.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane10.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- textPane2 ---- + textPane2.setText("disabled"); + textPane2.setEnabled(false); + scrollPane10.setViewportView(textPane2); + } + add(scrollPane10, "cell 2 12,growx"); + + //======== scrollPane11 ======== + { + scrollPane11.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane11.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- textPane3 ---- + textPane3.setText("not editable"); + textPane3.setEditable(false); + scrollPane11.setViewportView(textPane3); + } + add(scrollPane11, "cell 3 12,growx"); + + //======== scrollPane12 ======== + { + scrollPane12.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); + scrollPane12.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + + //---- textPane4 ---- + textPane4.setText("not editable disabled"); + textPane4.setEditable(false); + textPane4.setEnabled(false); + scrollPane12.setViewportView(textPane4); + } + add(scrollPane12, "cell 4 12,growx"); + + //---- textPane5 ---- + textPane5.setText("no scroll pane"); + add(textPane5, "cell 5 12,growx"); + // 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-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.jfd new file mode 100644 index 00000000..f50d7e6b --- /dev/null +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/BasicComponentsPanel.jfd @@ -0,0 +1,530 @@ +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": "ltr,hidemode 3" + "$columnConstraints": "[][][][][][]" + "$rowConstraints": "[][][][][][][][][][][][][]" + } ) { + name: "this" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "labelLabel" + "text": "JLabel:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label1" + "text": "enabled" + "displayedMnemonic": 69 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "label2" + "text": "disabled" + "displayedMnemonic": 68 + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "buttonLabel" + "text": "JButton:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1" + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "button1" + "text": "enabled" + "displayedMnemonicIndex": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 1" + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "button2" + "text": "disabled" + "displayedMnemonicIndex": 0 + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "toggleButtonLabel" + "text": "JToggleButton:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 2" + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "toggleButton1" + "text": "enabled" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 2" + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "toggleButton2" + "text": "disabled" + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 2" + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "toggleButton3" + "text": "selected" + "selected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 2" + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "toggleButton4" + "text": "selected disabled" + "enabled": false + "selected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 2" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "checkBoxLabel" + "text": "JCheckBox" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 3" + } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "checkBox1" + "text": "enabled" + "mnemonic": 65 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 3" + } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "checkBox2" + "text": "disabled" + "enabled": false + "mnemonic": 68 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 3" + } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "checkBox3" + "text": "selected" + "selected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 3" + } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "checkBox4" + "text": "selected disabled" + "selected": true + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 3" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "radioButtonLabel" + "text": "JRadioButton:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 4" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "radioButton1" + "text": "enabled" + "mnemonic": 78 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 4" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "radioButton2" + "text": "disabled" + "enabled": false + "mnemonic": 83 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 4" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "radioButton3" + "text": "selected" + "selected": true + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 4" + } ) + add( new FormComponent( "javax.swing.JRadioButton" ) { + name: "radioButton4" + "text": "selected disabled" + "selected": true + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 4" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "comboBoxLabel" + "text": "JComboBox:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 5" + } ) + add( new FormComponent( "javax.swing.JComboBox" ) { + name: "comboBox1" + "editable": true + "model": new javax.swing.DefaultComboBoxModel { + selectedItem: "editable" + addElement( "editable" ) + addElement( "a" ) + addElement( "bb" ) + addElement( "ccc" ) + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 5,growx" + } ) + add( new FormComponent( "javax.swing.JComboBox" ) { + name: "comboBox2" + "editable": true + "enabled": false + "model": new javax.swing.DefaultComboBoxModel { + selectedItem: "disabled" + addElement( "disabled" ) + addElement( "a" ) + addElement( "bb" ) + addElement( "ccc" ) + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 5,growx" + } ) + add( new FormComponent( "javax.swing.JComboBox" ) { + name: "comboBox3" + "model": new javax.swing.DefaultComboBoxModel { + selectedItem: "not editable" + addElement( "not editable" ) + addElement( "a" ) + addElement( "bb" ) + addElement( "ccc" ) + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 5,growx" + } ) + add( new FormComponent( "javax.swing.JComboBox" ) { + name: "comboBox4" + "model": new javax.swing.DefaultComboBoxModel { + selectedItem: "not editable disabled" + addElement( "not editable disabled" ) + addElement( "a" ) + addElement( "bb" ) + addElement( "ccc" ) + } + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 5,growx" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "spinnerLabel" + "text": "JSpinner:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 6" + } ) + add( new FormComponent( "javax.swing.JSpinner" ) { + name: "spinner1" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 6,growx" + } ) + add( new FormComponent( "javax.swing.JSpinner" ) { + name: "spinner2" + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 6,growx" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "textFieldLabel" + "text": "JTextField:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 7" + } ) + add( new FormComponent( "javax.swing.JTextField" ) { + name: "textField1" + "text": "editable" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 7,growx" + } ) + add( new FormComponent( "javax.swing.JTextField" ) { + name: "textField2" + "text": "disabled" + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 7,growx" + } ) + add( new FormComponent( "javax.swing.JTextField" ) { + name: "textField3" + "text": "not editable" + "editable": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 7,growx" + } ) + add( new FormComponent( "javax.swing.JTextField" ) { + name: "textField4" + "text": "not editable disabled" + "enabled": false + "editable": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 7,growx" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "formattedTextFieldLabel" + "text": "JFormattedTextField:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 8" + } ) + add( new FormComponent( "javax.swing.JFormattedTextField" ) { + name: "formattedTextField1" + "text": "editable" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 8,growx" + } ) + add( new FormComponent( "javax.swing.JFormattedTextField" ) { + name: "formattedTextField2" + "text": "disabled" + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 8,growx" + } ) + add( new FormComponent( "javax.swing.JFormattedTextField" ) { + name: "formattedTextField3" + "text": "not editable" + "editable": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 8,growx" + } ) + add( new FormComponent( "javax.swing.JFormattedTextField" ) { + name: "formattedTextField4" + "text": "not editable disabled" + "enabled": false + "editable": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 8,growx" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "passwordFieldLabel" + "text": "JPasswordField:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 9" + } ) + add( new FormComponent( "javax.swing.JPasswordField" ) { + name: "passwordField1" + "text": "editable" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 9,growx" + } ) + add( new FormComponent( "javax.swing.JPasswordField" ) { + name: "passwordField2" + "text": "disabled" + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 9,growx" + } ) + add( new FormComponent( "javax.swing.JPasswordField" ) { + name: "passwordField3" + "text": "not editable" + "editable": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 9,growx" + } ) + add( new FormComponent( "javax.swing.JPasswordField" ) { + name: "passwordField4" + "text": "not editable disabled" + "enabled": false + "editable": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 9,growx" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "textAreaLabel" + "text": "JTextArea:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 10" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane1" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JTextArea" ) { + name: "textArea1" + "text": "editable" + "rows": 2 + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 10,growx" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane2" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JTextArea" ) { + name: "textArea2" + "text": "disabled" + "rows": 2 + "enabled": false + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 10,growx" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane3" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JTextArea" ) { + name: "textArea3" + "text": "not editable" + "rows": 2 + "editable": false + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 10,growx" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane4" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JTextArea" ) { + name: "textArea4" + "text": "not editable disabled" + "rows": 2 + "editable": false + "enabled": false + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 10,growx" + } ) + add( new FormComponent( "javax.swing.JTextArea" ) { + name: "textArea5" + "rows": 2 + "text": "no scroll pane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 5 10,growx" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "editorPaneLabel" + "text": "JEditorPane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 11" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane5" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JEditorPane" ) { + name: "editorPane1" + "text": "editable" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 11,growx" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane6" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JEditorPane" ) { + name: "editorPane2" + "text": "disabled" + "enabled": false + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 11,growx" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane7" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JEditorPane" ) { + name: "editorPane3" + "text": "not editable" + "editable": false + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 11,growx" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane8" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JEditorPane" ) { + name: "editorPane4" + "text": "not editable disabled" + "editable": false + "enabled": false + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 11,growx" + } ) + add( new FormComponent( "javax.swing.JEditorPane" ) { + name: "editorPane5" + "text": "no scroll pane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 5 11,growx" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "textPaneLabel" + "text": "JTextPane:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 12" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane9" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JTextPane" ) { + name: "textPane1" + "text": "editable" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 12,growx" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane10" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JTextPane" ) { + name: "textPane2" + "text": "disabled" + "enabled": false + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 12,growx" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane11" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JTextPane" ) { + name: "textPane3" + "text": "not editable" + "editable": false + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 12,growx" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane12" + "verticalScrollBarPolicy": 21 + "horizontalScrollBarPolicy": 31 + add( new FormComponent( "javax.swing.JTextPane" ) { + name: "textPane4" + "text": "not editable disabled" + "editable": false + "enabled": false + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 12,growx" + } ) + add( new FormComponent( "javax.swing.JTextPane" ) { + name: "textPane5" + "text": "no scroll pane" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 5 12,growx" + } ) + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 0 ) + "size": new java.awt.Dimension( 790, 715 ) + } ) + } +} diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/ControlBar.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/ControlBar.java new file mode 100644 index 00000000..d2bb7526 --- /dev/null +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/ControlBar.java @@ -0,0 +1,285 @@ +/* + * 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.demo; + +import java.awt.*; +import java.awt.event.KeyEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.prefs.Preferences; +import javax.swing.*; +import javax.swing.plaf.metal.MetalLookAndFeel; +import javax.swing.plaf.nimbus.NimbusLookAndFeel; +import com.formdev.flatlaf.*; +import com.formdev.flatlaf.util.SystemInfo; +import net.miginfocom.swing.*; + +/** + * @author Karl Tauber + */ +class ControlBar + extends JPanel +{ + private JFrame frame; + private JTabbedPane tabbedPane; + + ControlBar() { + initComponents(); + + // initialize look and feels combo box + DefaultComboBoxModel lafModel = new DefaultComboBoxModel<>(); + lafModel.addElement( new LafInfo( "Flat Light (F1)", FlatLightLaf.class.getName() ) ); + lafModel.addElement( new LafInfo( "Flat Dark (F2)", FlatDarkLaf.class.getName() ) ); + + UIManager.LookAndFeelInfo[] lookAndFeels = UIManager.getInstalledLookAndFeels(); + for( UIManager.LookAndFeelInfo lookAndFeel : lookAndFeels ) { + String name = lookAndFeel.getName(); + String className = lookAndFeel.getClassName(); + if( className.equals( "com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel" ) || + className.equals( "com.sun.java.swing.plaf.motif.MotifLookAndFeel" ) ) + continue; + + if( className.equals( NimbusLookAndFeel.class.getName() ) ) + name += " (F10)"; + else if( className.equals( MetalLookAndFeel.class.getName() ) ) + name += " (F11)"; + else if( className.equals( "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" ) ) + name += " (F12)"; + + lafModel.addElement( new LafInfo( name, className ) ); + } + + LookAndFeel activeLaf = UIManager.getLookAndFeel(); + String activeLafClassName = activeLaf.getClass().getName(); + int sel = lafModel.getIndexOf( new LafInfo( null, activeLafClassName ) ); + if( sel < 0 ) { + lafModel.addElement( new LafInfo( activeLaf.getName(), activeLafClassName ) ); + sel = lafModel.getSize() - 1; + } + lafModel.setSelectedItem( lafModel.getElementAt( sel ) ); + + lookAndFeelComboBox.setModel( lafModel ); + } + + void initialize( JFrame frame, JTabbedPane tabbedPane ) { + this.frame = frame; + this.tabbedPane = tabbedPane; + + // register F1, F2, ... keys to switch to Light, Dark or other LaFs + registerSwitchToLookAndFeel( KeyEvent.VK_F1, FlatLightLaf.class.getName() ); + registerSwitchToLookAndFeel( KeyEvent.VK_F2, FlatDarkLaf.class.getName() ); + + registerSwitchToLookAndFeel( KeyEvent.VK_F10, NimbusLookAndFeel.class.getName() ); + registerSwitchToLookAndFeel( KeyEvent.VK_F11, MetalLookAndFeel.class.getName() ); + if( SystemInfo.IS_WINDOWS ) + registerSwitchToLookAndFeel( KeyEvent.VK_F12, "com.sun.java.swing.plaf.windows.WindowsLookAndFeel" ); + + // register ESC key to close frame + ((JComponent)frame.getContentPane()).registerKeyboardAction( + e -> { + frame.dispose(); + }, + KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0, false ), + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ); + + // make the "close" button the default button + frame.getRootPane().setDefaultButton( closeButton ); + + // move focus to "close" button + frame.addWindowListener( new WindowAdapter() { + @Override + public void windowOpened( WindowEvent e ) { + closeButton.requestFocusInWindow(); + } + } ); + } + + private void registerSwitchToLookAndFeel( int keyCode, String lafClassName ) { + ((JComponent)frame.getContentPane()).registerKeyboardAction( + e -> { + selectLookAndFeel( lafClassName ); + }, + KeyStroke.getKeyStroke( keyCode, 0, false ), + JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT ); + } + + private void selectLookAndFeel( String lafClassName ) { + DefaultComboBoxModel lafModel = (DefaultComboBoxModel) lookAndFeelComboBox.getModel(); + int sel = lafModel.getIndexOf( new LafInfo( null, lafClassName ) ); + if( sel >= 0 ) + lookAndFeelComboBox.setSelectedIndex( sel ); + } + + private void lookAndFeelChanged() { + LafInfo newLaf = (LafInfo) lookAndFeelComboBox.getSelectedItem(); + if( newLaf == null ) + return; + + if( newLaf.className.equals( UIManager.getLookAndFeel().getClass().getName() ) ) + return; + + Preferences.userRoot().node( FlatLafDemo.PREFS_ROOT_PATH ).put( FlatLafDemo.KEY_LAF, newLaf.className ); + + EventQueue.invokeLater( () -> { + try { + // change look and feel + UIManager.setLookAndFeel( newLaf.className ); + + // update all components + SwingUtilities.updateComponentTreeUI( frame ); + + // increase size of frame if necessary + int width = frame.getWidth(); + int height = frame.getHeight(); + Dimension prefSize = frame.getPreferredSize(); + if( prefSize.width > width || prefSize.height > height ) + frame.setSize( Math.max( prefSize.width, width ), Math.max( prefSize.height, height ) ); + + } catch( Exception ex ) { + ex.printStackTrace(); + } + } ); + } + + private void rightToLeftChanged() { + boolean rightToLeft = rightToLeftCheckBox.isSelected(); + int tabCount = tabbedPane.getTabCount(); + for( int i = 0; i < tabCount; i++ ) + rightToLeftChanged( (Container) tabbedPane.getComponentAt( i ), rightToLeft ); + } + + private void rightToLeftChanged( Container c, boolean rightToLeft ) { + c.applyComponentOrientation( rightToLeft + ? ComponentOrientation.RIGHT_TO_LEFT + : ComponentOrientation.LEFT_TO_RIGHT ); + c.revalidate(); + c.repaint(); + } + + private void enabledChanged() { + enabledDisable( tabbedPane, enabledCheckBox.isSelected() ); + } + + private void enabledDisable( Container container, boolean enabled ) { + for( Component c : container.getComponents() ) { + if( c instanceof JPanel ) { + enabledDisable( (JPanel) c, enabled ); + continue; + } + + c.setEnabled( enabled ); + + if( c instanceof JScrollPane ) { + Component view = ((JScrollPane)c).getViewport().getView(); + if( view != null ) + view.setEnabled( enabled ); + } else if( c instanceof JTabbedPane ) { + JTabbedPane tabPane = (JTabbedPane)c; + int tabCount = tabPane.getTabCount(); + for( int i = 0; i < tabCount; i++ ) { + Component tab = tabPane.getComponentAt( i ); + if( tab != null ) + tab.setEnabled( enabled ); + } + } + + if( c instanceof JToolBar ) + enabledDisable( (JToolBar) c, enabled ); + } + } + + private void closePerformed() { + frame.dispose(); + } + + private void initComponents() { + // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents + separator1 = new JSeparator(); + lookAndFeelComboBox = new JComboBox<>(); + rightToLeftCheckBox = new JCheckBox(); + enabledCheckBox = new JCheckBox(); + closeButton = new JButton(); + + //======== this ======== + setLayout(new MigLayout( + "insets 0", + // columns + "[fill]" + + "[fill]" + + "[fill]" + + "[grow,fill]" + + "[button,fill]", + // rows + "[20,bottom]" + + "[]")); + add(separator1, "cell 0 0 5 1"); + + //---- lookAndFeelComboBox ---- + lookAndFeelComboBox.addActionListener(e -> lookAndFeelChanged()); + add(lookAndFeelComboBox, "cell 0 1"); + + //---- rightToLeftCheckBox ---- + rightToLeftCheckBox.setText("right-to-left"); + rightToLeftCheckBox.setMnemonic('R'); + rightToLeftCheckBox.addActionListener(e -> rightToLeftChanged()); + add(rightToLeftCheckBox, "cell 1 1"); + + //---- enabledCheckBox ---- + enabledCheckBox.setText("enabled"); + enabledCheckBox.setMnemonic('E'); + enabledCheckBox.setSelected(true); + enabledCheckBox.addActionListener(e -> enabledChanged()); + add(enabledCheckBox, "cell 2 1"); + + //---- closeButton ---- + closeButton.setText("Close"); + closeButton.addActionListener(e -> closePerformed()); + add(closeButton, "cell 4 1"); + // JFormDesigner - End of component initialization //GEN-END:initComponents + } + + // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables + private JSeparator separator1; + private JComboBox lookAndFeelComboBox; + private JCheckBox rightToLeftCheckBox; + private JCheckBox enabledCheckBox; + private JButton closeButton; + // JFormDesigner - End of variables declaration //GEN-END:variables + + //---- class LafInfo ------------------------------------------------------ + + static class LafInfo + { + final String name; + final String className; + + LafInfo( String name, String className ) { + this.name = name; + this.className = className; + } + + @Override + public boolean equals( Object obj ) { + return obj instanceof LafInfo && className.equals( ((LafInfo)obj).className ); + } + + @Override + public String toString() { + return name; + } + } +} diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/ControlBar.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/ControlBar.jfd new file mode 100644 index 00000000..8430f592 --- /dev/null +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/ControlBar.jfd @@ -0,0 +1,56 @@ +JFDML JFormDesigner: "7.0.0.0.194" Java: "11.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": "insets 0" + "$columnConstraints": "[fill][fill][fill][grow,fill][button,fill]" + "$rowSpecs": "[fill]" + "$rowConstraints": "[20,bottom][]" + } ) { + name: "this" + add( new FormComponent( "javax.swing.JSeparator" ) { + name: "separator1" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0 5 1" + } ) + add( new FormComponent( "javax.swing.JComboBox" ) { + name: "lookAndFeelComboBox" + auxiliary() { + "JavaCodeGenerator.typeParameters": "LafInfo" + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "lookAndFeelChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1" + } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "rightToLeftCheckBox" + "text": "right-to-left" + "mnemonic": 82 + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "rightToLeftChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 1" + } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "enabledCheckBox" + "text": "enabled" + "mnemonic": 69 + "selected": true + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "enabledChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 1" + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "closeButton" + "text": "Close" + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "closePerformed", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 1" + } ) + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 0 ) + "size": new java.awt.Dimension( 398, 45 ) + } ) + } +} 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 new file mode 100644 index 00000000..b35c45df --- /dev/null +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.java @@ -0,0 +1,74 @@ +/* + * 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.demo; + +import java.awt.*; +import javax.swing.*; +import net.miginfocom.swing.*; + +/** + * @author Karl Tauber + */ +class DemoFrame + extends JFrame +{ + DemoFrame() { + initComponents(); + controlBar.initialize( this, tabbedPane ); + } + + private void initComponents() { + // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents + JPanel contentPanel = new JPanel(); + tabbedPane = new JTabbedPane(); + BasicComponentsPanel basicComponentsPanel = new BasicComponentsPanel(); + MoreComponentsPanel moreComponentsPanel = new MoreComponentsPanel(); + controlBar = new ControlBar(); + + //======== this ======== + setTitle("FlatLaf Demo"); + setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); + Container contentPane = getContentPane(); + contentPane.setLayout(new BorderLayout()); + + //======== contentPanel ======== + { + contentPanel.setLayout(new MigLayout( + "insets dialog,hidemode 3", + // columns + "[grow,fill]", + // rows + "[grow,fill]" + + "[]")); + + //======== tabbedPane ======== + { + tabbedPane.addTab("Basic Components", basicComponentsPanel); + tabbedPane.addTab("More Components", moreComponentsPanel); + } + contentPanel.add(tabbedPane, "cell 0 0"); + contentPanel.add(controlBar, "cell 0 1"); + } + contentPane.add(contentPanel, BorderLayout.CENTER); + // JFormDesigner - End of component initialization //GEN-END:initComponents + } + + // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables + private JTabbedPane tabbedPane; + private ControlBar controlBar; + // JFormDesigner - End of variables declaration //GEN-END:variables +} 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 new file mode 100644 index 00000000..d66c6d2a --- /dev/null +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/DemoFrame.jfd @@ -0,0 +1,55 @@ +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 FormWindow( "javax.swing.JFrame", new FormLayoutManager( class java.awt.BorderLayout ) ) { + name: "this" + "title": "FlatLaf Demo" + "defaultCloseOperation": 2 + "$locationPolicy": 2 + "$sizePolicy": 2 + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { + "$layoutConstraints": "insets dialog,hidemode 3" + "$columnConstraints": "[grow,fill]" + "$rowConstraints": "[grow,fill][]" + } ) { + name: "contentPanel" + add( new FormContainer( "javax.swing.JTabbedPane", new FormLayoutManager( class javax.swing.JTabbedPane ) ) { + name: "tabbedPane" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + add( new FormComponent( "com.formdev.flatlaf.demo.BasicComponentsPanel" ) { + name: "basicComponentsPanel" + }, new FormLayoutConstraints( null ) { + "title": "Basic Components" + } ) + add( new FormComponent( "com.formdev.flatlaf.demo.MoreComponentsPanel" ) { + name: "moreComponentsPanel" + }, new FormLayoutConstraints( null ) { + "title": "More Components" + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormComponent( "com.formdev.flatlaf.demo.ControlBar" ) { + name: "controlBar" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1" + } ) + }, new FormLayoutConstraints( class java.lang.String ) { + "value": "Center" + } ) + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 0 ) + "size": new java.awt.Dimension( 800, 710 ) + } ) + } +} diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/FlatLafDemo.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/FlatLafDemo.java new file mode 100644 index 00000000..4fbe6fa6 --- /dev/null +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/FlatLafDemo.java @@ -0,0 +1,61 @@ +/* + * 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.demo; + +import java.util.prefs.Preferences; +import javax.swing.UIManager; +import com.formdev.flatlaf.FlatLightLaf; + +/** + * @author Karl Tauber + */ +public class FlatLafDemo +{ + static final String PREFS_ROOT_PATH = "/flatlaf-demo"; + static final String KEY_LAF = "laf"; + + public static void main( String[] args ) { + // set look and feel + try { + if( args.length > 0 ) + UIManager.setLookAndFeel( args[0] ); + else { + String lafClassName = Preferences.userRoot().node( PREFS_ROOT_PATH ) + .get( KEY_LAF, FlatLightLaf.class.getName() ); + UIManager.setLookAndFeel( lafClassName ); + } + } catch( Exception ex ) { + ex.printStackTrace(); + + // fallback + try { + UIManager.setLookAndFeel( new FlatLightLaf() ); + } catch( Exception ex2 ) { + ex2.printStackTrace(); + } + } + + // create frame + DemoFrame frame = new DemoFrame(); + frame.setTitle( frame.getTitle() + " (Java " + System.getProperty( "java.version" ) + ")" ); + + // show frame + frame.pack(); + frame.setLocationRelativeTo( null ); + frame.setVisible( true ); + } +} diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.java b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.java new file mode 100644 index 00000000..ebd69463 --- /dev/null +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.java @@ -0,0 +1,297 @@ +/* + * 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.demo; + +import java.awt.*; +import javax.swing.*; +import net.miginfocom.swing.*; + +/** + * @author Karl Tauber + */ +class MoreComponentsPanel + extends JPanel +{ + MoreComponentsPanel() { + initComponents(); + } + + private void indeterminateCheckBoxActionPerformed() { + boolean indeterminate = indeterminateCheckBox.isSelected(); + progressBar1.setIndeterminate( indeterminate ); + progressBar2.setIndeterminate( indeterminate ); + progressBar3.setIndeterminate( indeterminate ); + progressBar4.setIndeterminate( indeterminate ); + } + + private void initComponents() { + // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents + JLabel scrollPaneLabel = new JLabel(); + JScrollPane scrollPane13 = new JScrollPane(); + JPanel panel1 = new JPanel(); + JScrollBar scrollBar2 = new JScrollBar(); + JScrollBar scrollBar3 = new JScrollBar(); + JSeparator separator2 = new JSeparator(); + JSlider slider2 = new JSlider(); + JSlider slider4 = new JSlider(); + JScrollPane scrollPane14 = new JScrollPane(); + progressBar3 = new JProgressBar(); + progressBar4 = new JProgressBar(); + JToolBar toolBar2 = new JToolBar(); + JButton button9 = new JButton(); + JButton button10 = new JButton(); + JButton button11 = new JButton(); + JToggleButton toggleButton7 = new JToggleButton(); + JLabel scrollBarLabel = new JLabel(); + JScrollBar scrollBar1 = new JScrollBar(); + JScrollBar scrollBar4 = new JScrollBar(); + JLabel separatorLabel = new JLabel(); + JSeparator separator1 = new JSeparator(); + JLabel sliderLabel = new JLabel(); + JSlider slider1 = new JSlider(); + JSlider slider6 = new JSlider(); + JSlider slider3 = new JSlider(); + JSlider slider5 = new JSlider(); + JLabel progressBarLabel = new JLabel(); + progressBar1 = new JProgressBar(); + progressBar2 = new JProgressBar(); + indeterminateCheckBox = new JCheckBox(); + JLabel toolTipLabel = new JLabel(); + JToolTip toolTip1 = new JToolTip(); + JLabel toolBarLabel = new JLabel(); + JToolBar toolBar1 = new JToolBar(); + JButton button4 = new JButton(); + JButton button6 = new JButton(); + JButton button7 = new JButton(); + JButton button8 = new JButton(); + JToggleButton toggleButton6 = new JToggleButton(); + + //======== this ======== + setLayout(new MigLayout( + "ltr,hidemode 3", + // columns + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]", + // rows + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]" + + "[]")); + + //---- scrollPaneLabel ---- + scrollPaneLabel.setText("JScrollPane:"); + add(scrollPaneLabel, "cell 0 0"); + + //======== scrollPane13 ======== + { + scrollPane13.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); + scrollPane13.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); + + //======== panel1 ======== + { + panel1.setPreferredSize(new Dimension(200, 200)); + panel1.setLayout(new BorderLayout()); + } + scrollPane13.setViewportView(panel1); + } + add(scrollPane13, "cell 1 0,grow,width 70,height 70"); + add(scrollBar2, "cell 2 0 1 4,growy"); + + //---- scrollBar3 ---- + scrollBar3.setEnabled(false); + add(scrollBar3, "cell 2 0 1 4,growy"); + + //---- separator2 ---- + separator2.setOrientation(SwingConstants.VERTICAL); + add(separator2, "cell 2 0 1 4,growy"); + + //---- slider2 ---- + slider2.setOrientation(SwingConstants.VERTICAL); + slider2.setValue(30); + add(slider2, "cell 2 0 1 4,growy"); + + //---- slider4 ---- + slider4.setMinorTickSpacing(10); + slider4.setPaintTicks(true); + slider4.setMajorTickSpacing(50); + slider4.setPaintLabels(true); + slider4.setOrientation(SwingConstants.VERTICAL); + slider4.setValue(30); + add(slider4, "cell 2 0 1 4,growy"); + add(scrollPane14, "cell 3 0,grow"); + + //---- progressBar3 ---- + progressBar3.setOrientation(SwingConstants.VERTICAL); + progressBar3.setValue(50); + add(progressBar3, "cell 4 0 1 4,growy"); + + //---- progressBar4 ---- + progressBar4.setOrientation(SwingConstants.VERTICAL); + progressBar4.setValue(55); + progressBar4.setStringPainted(true); + add(progressBar4, "cell 4 0 1 4,growy"); + + //======== toolBar2 ======== + { + toolBar2.setOrientation(SwingConstants.VERTICAL); + + //---- button9 ---- + button9.setIcon(UIManager.getIcon("Tree.closedIcon")); + toolBar2.add(button9); + + //---- button10 ---- + button10.setIcon(UIManager.getIcon("Tree.openIcon")); + toolBar2.add(button10); + toolBar2.addSeparator(); + + //---- button11 ---- + button11.setIcon(UIManager.getIcon("Tree.leafIcon")); + toolBar2.add(button11); + + //---- toggleButton7 ---- + toggleButton7.setIcon(UIManager.getIcon("Tree.closedIcon")); + toolBar2.add(toggleButton7); + } + add(toolBar2, "cell 4 0 1 4,growy"); + + //---- scrollBarLabel ---- + scrollBarLabel.setText("JScrollBar:"); + add(scrollBarLabel, "cell 0 1"); + + //---- scrollBar1 ---- + scrollBar1.setOrientation(Adjustable.HORIZONTAL); + add(scrollBar1, "cell 1 1,growx"); + + //---- scrollBar4 ---- + scrollBar4.setOrientation(Adjustable.HORIZONTAL); + scrollBar4.setEnabled(false); + add(scrollBar4, "cell 1 2,growx"); + + //---- separatorLabel ---- + separatorLabel.setText("JSeparator:"); + add(separatorLabel, "cell 0 3"); + add(separator1, "cell 1 3,growx"); + + //---- sliderLabel ---- + sliderLabel.setText("JSlider:"); + add(sliderLabel, "cell 0 4"); + + //---- slider1 ---- + slider1.setValue(30); + add(slider1, "cell 1 4 3 1,aligny top,grow 100 0"); + + //---- slider6 ---- + slider6.setEnabled(false); + slider6.setValue(30); + add(slider6, "cell 1 4 3 1,aligny top,growy 0"); + + //---- slider3 ---- + slider3.setMinorTickSpacing(10); + slider3.setPaintTicks(true); + slider3.setMajorTickSpacing(50); + slider3.setPaintLabels(true); + slider3.setValue(30); + add(slider3, "cell 1 5 3 1,aligny top,grow 100 0"); + + //---- slider5 ---- + slider5.setMinorTickSpacing(10); + slider5.setPaintTicks(true); + slider5.setMajorTickSpacing(50); + slider5.setPaintLabels(true); + slider5.setEnabled(false); + slider5.setValue(30); + add(slider5, "cell 1 5 3 1,aligny top,growy 0"); + + //---- progressBarLabel ---- + progressBarLabel.setText("JProgressBar:"); + add(progressBarLabel, "cell 0 6"); + + //---- progressBar1 ---- + progressBar1.setValue(50); + add(progressBar1, "cell 1 6 3 1,growx"); + + //---- progressBar2 ---- + progressBar2.setStringPainted(true); + progressBar2.setValue(55); + add(progressBar2, "cell 1 6 3 1,growx"); + + //---- indeterminateCheckBox ---- + indeterminateCheckBox.setText("indeterminate"); + indeterminateCheckBox.addActionListener(e -> indeterminateCheckBoxActionPerformed()); + add(indeterminateCheckBox, "cell 4 6"); + + //---- toolTipLabel ---- + toolTipLabel.setText("JToolTip:"); + add(toolTipLabel, "cell 0 7"); + + //---- toolTip1 ---- + toolTip1.setTipText("Some text in tool tip."); + add(toolTip1, "cell 1 7 3 1"); + + //---- toolBarLabel ---- + toolBarLabel.setText("JToolBar:"); + add(toolBarLabel, "cell 0 8"); + + //======== toolBar1 ======== + { + + //---- button4 ---- + button4.setIcon(UIManager.getIcon("Tree.closedIcon")); + toolBar1.add(button4); + + //---- button6 ---- + button6.setIcon(UIManager.getIcon("Tree.openIcon")); + toolBar1.add(button6); + toolBar1.addSeparator(); + + //---- button7 ---- + button7.setIcon(UIManager.getIcon("Tree.leafIcon")); + toolBar1.add(button7); + toolBar1.addSeparator(); + + //---- button8 ---- + button8.setText("Text"); + button8.setIcon(UIManager.getIcon("Tree.expandedIcon")); + toolBar1.add(button8); + + //---- toggleButton6 ---- + toggleButton6.setText("Toggle"); + toggleButton6.setIcon(UIManager.getIcon("Tree.leafIcon")); + toggleButton6.setSelected(true); + toolBar1.add(toggleButton6); + } + add(toolBar1, "cell 1 8 3 1,growx"); + // JFormDesigner - End of component initialization //GEN-END:initComponents + } + + // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables + private JProgressBar progressBar3; + private JProgressBar progressBar4; + private JProgressBar progressBar1; + private JProgressBar progressBar2; + private JCheckBox indeterminateCheckBox; + // JFormDesigner - End of variables declaration //GEN-END:variables +} diff --git a/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.jfd b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.jfd new file mode 100644 index 00000000..b4d8b0ae --- /dev/null +++ b/flatlaf-demo/src/main/java/com/formdev/flatlaf/demo/MoreComponentsPanel.jfd @@ -0,0 +1,280 @@ +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": "ltr,hidemode 3" + "$columnConstraints": "[][][][][][]" + "$rowConstraints": "[][][][][][][][][]" + } ) { + name: "this" + add( new FormComponent( "javax.swing.JLabel" ) { + name: "scrollPaneLabel" + "text": "JScrollPane:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 0" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane13" + "horizontalScrollBarPolicy": 32 + "verticalScrollBarPolicy": 22 + add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class java.awt.BorderLayout ) ) { + name: "panel1" + "preferredSize": new java.awt.Dimension( 200, 200 ) + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 0,grow,width 70,height 70" + } ) + add( new FormComponent( "javax.swing.JScrollBar" ) { + name: "scrollBar2" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 0 1 4,growy" + } ) + add( new FormComponent( "javax.swing.JScrollBar" ) { + name: "scrollBar3" + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 0 1 4,growy" + } ) + add( new FormComponent( "javax.swing.JSeparator" ) { + name: "separator2" + "orientation": 1 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 0 1 4,growy" + } ) + add( new FormComponent( "javax.swing.JSlider" ) { + name: "slider2" + "orientation": 1 + "value": 30 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 0 1 4,growy" + } ) + add( new FormComponent( "javax.swing.JSlider" ) { + name: "slider4" + "minorTickSpacing": 10 + "paintTicks": true + "majorTickSpacing": 50 + "paintLabels": true + "orientation": 1 + "value": 30 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 0 1 4,growy" + } ) + add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { + name: "scrollPane14" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 0,grow" + } ) + add( new FormComponent( "javax.swing.JProgressBar" ) { + name: "progressBar3" + "orientation": 1 + "value": 50 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 0 1 4,growy" + } ) + add( new FormComponent( "javax.swing.JProgressBar" ) { + name: "progressBar4" + "orientation": 1 + "value": 55 + "stringPainted": true + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 0 1 4,growy" + } ) + add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { + name: "toolBar2" + "orientation": 1 + add( new FormComponent( "javax.swing.JButton" ) { + name: "button9" + "icon": &SwingIcon0 new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" ) + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "button10" + "icon": &SwingIcon1 new com.jformdesigner.model.SwingIcon( 2, "Tree.openIcon" ) + } ) + add( new FormComponent( "javax.swing.JToolBar$Separator" ) { + name: "separator5" + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "button11" + "icon": &SwingIcon2 new com.jformdesigner.model.SwingIcon( 2, "Tree.leafIcon" ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "toggleButton7" + "icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" ) + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 0 1 4,growy" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "scrollBarLabel" + "text": "JScrollBar:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 1" + } ) + add( new FormComponent( "javax.swing.JScrollBar" ) { + name: "scrollBar1" + "orientation": 0 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 1,growx" + } ) + add( new FormComponent( "javax.swing.JScrollBar" ) { + name: "scrollBar4" + "orientation": 0 + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 2,growx" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "separatorLabel" + "text": "JSeparator:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 3" + } ) + add( new FormComponent( "javax.swing.JSeparator" ) { + name: "separator1" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 3,growx" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "sliderLabel" + "text": "JSlider:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 4" + } ) + add( new FormComponent( "javax.swing.JSlider" ) { + name: "slider1" + "value": 30 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 4 3 1,aligny top,grow 100 0" + } ) + add( new FormComponent( "javax.swing.JSlider" ) { + name: "slider6" + "enabled": false + "value": 30 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 4 3 1,aligny top,growy 0" + } ) + add( new FormComponent( "javax.swing.JSlider" ) { + name: "slider3" + "minorTickSpacing": 10 + "paintTicks": true + "majorTickSpacing": 50 + "paintLabels": true + "value": 30 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 5 3 1,aligny top,grow 100 0" + } ) + add( new FormComponent( "javax.swing.JSlider" ) { + name: "slider5" + "minorTickSpacing": 10 + "paintTicks": true + "majorTickSpacing": 50 + "paintLabels": true + "enabled": false + "value": 30 + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 5 3 1,aligny top,growy 0" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "progressBarLabel" + "text": "JProgressBar:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 6" + } ) + add( new FormComponent( "javax.swing.JProgressBar" ) { + name: "progressBar1" + "value": 50 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 6 3 1,growx" + } ) + add( new FormComponent( "javax.swing.JProgressBar" ) { + name: "progressBar2" + "stringPainted": true + "value": 55 + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 6 3 1,growx" + } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "indeterminateCheckBox" + "text": "indeterminate" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "indeterminateCheckBoxActionPerformed", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 6" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "toolTipLabel" + "text": "JToolTip:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 7" + } ) + add( new FormComponent( "javax.swing.JToolTip" ) { + name: "toolTip1" + "tipText": "Some text in tool tip." + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 7 3 1" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "toolBarLabel" + "text": "JToolBar:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 8" + } ) + add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { + name: "toolBar1" + add( new FormComponent( "javax.swing.JButton" ) { + name: "button4" + "icon": #SwingIcon0 + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "button6" + "icon": #SwingIcon1 + } ) + add( new FormComponent( "javax.swing.JToolBar$Separator" ) { + name: "separator3" + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "button7" + "icon": #SwingIcon2 + } ) + add( new FormComponent( "javax.swing.JToolBar$Separator" ) { + name: "separator4" + } ) + add( new FormComponent( "javax.swing.JButton" ) { + name: "button8" + "text": "Text" + "icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.expandedIcon" ) + } ) + add( new FormComponent( "javax.swing.JToggleButton" ) { + name: "toggleButton6" + "text": "Toggle" + "icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.leafIcon" ) + "selected": true + } ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 8 3 1,growx" + } ) + }, new FormLayoutConstraints( null ) { + "location": new java.awt.Point( 0, 0 ) + "size": new java.awt.Dimension( 790, 715 ) + } ) + } +} diff --git a/settings.gradle.kts b/settings.gradle.kts index 8a14cef8..82e75f4e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,3 +17,4 @@ rootProject.name = "FlatLaf" include( "flatlaf-core" ) +include( "flatlaf-demo" )