From 4aa3a52c802936060d90ef224d6429375913c457 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Thu, 5 Sep 2019 11:06:32 +0200 Subject: [PATCH] ToggleButton implementation --- .../com/formdev/flatlaf/ui/FlatButtonUI.java | 28 ++- .../flatlaf/ui/FlatToggleButtonUI.java | 92 ++++++++ .../formdev/flatlaf/FlatDarkLaf.properties | 7 + .../com/formdev/flatlaf/FlatLaf.properties | 17 ++ .../formdev/flatlaf/FlatLightLaf.properties | 7 + .../formdev/flatlaf/FlatComponentsTest.java | 191 ++++++++++------- .../formdev/flatlaf/FlatComponentsTest.jfd | 197 +++++++++++------- .../formdev/flatlaf/FlatTestLaf.properties | 8 + 8 files changed, 375 insertions(+), 172 deletions(-) create mode 100644 flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToggleButtonUI.java diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java index 70b08af9..710cc0c7 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatButtonUI.java @@ -71,14 +71,16 @@ public class FlatButtonUI protected void installDefaults( AbstractButton b ) { super.installDefaults( b ); - focusWidth = UIManager.getInt( "Component.focusWidth" ); - arc = UIManager.getInt( "Button.arc" ); + String prefix = getPropertyPrefix(); - disabledText = UIManager.getColor( "Button.disabledText" ); - defaultBackground = UIManager.getColor( "Button.default.background" ); - defaultForeground = UIManager.getColor( "Button.default.foreground" ); - toolbarHoverBackground = UIManager.getColor( "Button.toolbar.hoverBackground" ); - toolbarPressedBackground = UIManager.getColor( "Button.toolbar.pressedBackground" ); + focusWidth = UIManager.getInt( "Component.focusWidth" ); + arc = UIManager.getInt( prefix + "arc" ); + + disabledText = UIManager.getColor( prefix + "disabledText" ); + defaultBackground = UIManager.getColor( prefix + "default.background" ); + defaultForeground = UIManager.getColor( prefix + "default.foreground" ); + toolbarHoverBackground = UIManager.getColor( prefix + "toolbar.hoverBackground" ); + toolbarPressedBackground = UIManager.getColor( prefix + "toolbar.pressedBackground" ); } static boolean isContentAreaFilled( Component c ) { @@ -94,7 +96,8 @@ public class FlatButtonUI if( c.isOpaque() && isContentAreaFilled( c ) ) { FlatUIUtils.paintParentBackground( g, c ); - if( c.isEnabled() ) { + Color background = getBackground( c ); + if( background != null ) { Graphics2D g2 = (Graphics2D) g.create(); try { FlatUIUtils.setRenderingHints( g2 ); @@ -103,7 +106,7 @@ public class FlatButtonUI float focusWidth = (border instanceof FlatBorder) ? scale( (float) this.focusWidth ) : 0; float arc = (border instanceof FlatButtonBorder || FlatUIUtils.isToolBarButton( c )) ? scale( (float) this.arc ) : 0; - g2.setColor( getBackground( c ) ); + g2.setColor( background ); FlatUIUtils.fillRoundRectangle( g2, 0, 0, c.getWidth(), c.getHeight(), focusWidth, arc ); } finally { g2.dispose(); @@ -126,7 +129,10 @@ public class FlatButtonUI textRect.y + fm.getAscent() + getTextShiftOffset() ); } - private Color getBackground( JComponent c ) { + protected Color getBackground( JComponent c ) { + if( !c.isEnabled() ) + return null; + ButtonModel model = ((AbstractButton)c).getModel(); // toolbar button @@ -144,7 +150,7 @@ public class FlatButtonUI return def ? defaultBackground : c.getBackground(); } - private Color getForeground( Component c ) { + protected Color getForeground( JComponent c ) { boolean def = isDefaultButton( c ); return def ? defaultForeground : c.getForeground(); } diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToggleButtonUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToggleButtonUI.java new file mode 100644 index 00000000..0fb3c09a --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatToggleButtonUI.java @@ -0,0 +1,92 @@ +/* + * 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.ui; + +import java.awt.Color; +import javax.swing.AbstractButton; +import javax.swing.ButtonModel; +import javax.swing.JComponent; +import javax.swing.UIManager; +import javax.swing.plaf.ComponentUI; + +/** + * Provides the Flat LaF UI delegate for {@link javax.swing.JToggleButton}. + * + * TODO document used UI defaults of superclass + * + * @uiDefault Component.focusWidth int + * @uiDefault ToggleButton.arc int + * @uiDefault ToggleButton.disabledText Color + * @uiDefault ToggleButton.toolbar.hoverBackground Color + * @uiDefault ToggleButton.toolbar.pressedBackground Color + * @uiDefault ToggleButton.selectedBackground Color + * @uiDefault ToggleButton.selectedForeground Color + * + * @author Karl Tauber + */ +public class FlatToggleButtonUI + extends FlatButtonUI +{ + protected Color selectedBackground; + protected Color selectedForeground; + protected Color disabledSelectedBackground; + + private static ComponentUI instance; + + public static ComponentUI createUI( JComponent c ) { + if( instance == null ) + instance = new FlatToggleButtonUI(); + return instance; + } + + @Override + protected String getPropertyPrefix() { + return "ToggleButton."; + } + + @Override + protected void installDefaults( AbstractButton b ) { + super.installDefaults( b ); + + selectedBackground = UIManager.getColor( "ToggleButton.selectedBackground" ); + selectedForeground = UIManager.getColor( "ToggleButton.selectedForeground" ); + disabledSelectedBackground = UIManager.getColor( "ToggleButton.disabledSelectedBackground" ); + } + + @Override + protected Color getBackground( JComponent c ) { + ButtonModel model = ((AbstractButton)c).getModel(); + + if( model.isSelected() ) { + return FlatUIUtils.isToolBarButton( c ) + ? toolbarPressedBackground + : (c.isEnabled() ? selectedBackground : disabledSelectedBackground); + } + + return super.getBackground( c ); + } + + @Override + protected Color getForeground( JComponent c ) { + ButtonModel model = ((AbstractButton)c).getModel(); + + if( model.isSelected() && !FlatUIUtils.isToolBarButton( c ) ) + return selectedForeground; + + return super.getForeground( c ); + } +} diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties index e7fcd0d1..81a540e7 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties @@ -191,6 +191,13 @@ TableHeader.separatorColor=585858 TableHeader.bottomSeparatorColor=585858 +#---- ToggleButton ---- + +ToggleButton.selectedBackground=5c6164 +ToggleButton.selectedForeground=@foreground +ToggleButton.disabledSelectedBackground=525658 + + #---- ToolTip ---- ToolTip.background=4b4d4d diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties index 5363c71b..4ef71a53 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -45,6 +45,7 @@ TableHeaderUI=com.formdev.flatlaf.ui.FlatTableHeaderUI TextAreaUI=com.formdev.flatlaf.ui.FlatTextAreaUI TextFieldUI=com.formdev.flatlaf.ui.FlatTextFieldUI TextPaneUI=com.formdev.flatlaf.ui.FlatTextPaneUI +ToggleButtonUI=com.formdev.flatlaf.ui.FlatToggleButtonUI ToolBarUI=com.formdev.flatlaf.ui.FlatToolBarUI ToolBarSeparatorUI=com.formdev.flatlaf.ui.FlatToolBarSeparatorUI ToolTipUI=javax.swing.plaf.basic.BasicToolTipUI @@ -261,6 +262,22 @@ TextPane.background=@textComponentBackground TextPane.margin=@textComponentMargin +#---- ToggleButton ---- + +ToggleButton.border=com.formdev.flatlaf.ui.FlatButtonBorder +ToggleButton.arc=6 + +ToggleButton.background=@@Button.background + +ToggleButton.startBorderColor=@@Button.startBorderColor +ToggleButton.endBorderColor=@@Button.endBorderColor +ToggleButton.disabledBorderColor=@@Button.disabledBorderColor +ToggleButton.focusedBorderColor=@@Button.focusedBorderColor + +ToggleButton.toolbar.hoverBackground=@@Button.toolbar.hoverBackground +ToggleButton.toolbar.pressedBackground=@@Button.toolbar.pressedBackground + + #---- ToolBar ---- ToolBar.border=com.formdev.flatlaf.ui.FlatToolBarBorder diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties index b7419d03..da6b23cd 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties @@ -191,6 +191,13 @@ TableHeader.separatorColor=e5e5e5 TableHeader.bottomSeparatorColor=e5e5e5 +#---- ToggleButton ---- + +ToggleButton.selectedBackground=cfcfcf +ToggleButton.selectedForeground=@foreground +ToggleButton.disabledSelectedBackground=dfdfdf + + #---- ToolTip ---- ToolTip.background=f7f7f7 diff --git a/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatComponentsTest.java b/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatComponentsTest.java index b629e948..bce69b9f 100644 --- a/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatComponentsTest.java +++ b/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatComponentsTest.java @@ -52,6 +52,11 @@ public class FlatComponentsTest JButton button1 = new JButton(); JButton button2 = new JButton(); FlatComponentsTest.TestDefaultButton button5 = new FlatComponentsTest.TestDefaultButton(); + 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(); @@ -186,6 +191,7 @@ public class FlatComponentsTest "[]" + "[]" + "[]" + + "[]" + "[]")); //---- labelLabel ---- @@ -223,61 +229,85 @@ public class FlatComponentsTest button5.setDisplayedMnemonicIndex(0); add(button5, "cell 3 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 2"); + add(checkBoxLabel, "cell 0 3"); //---- checkBox1 ---- checkBox1.setText("enabled"); checkBox1.setMnemonic('A'); - add(checkBox1, "cell 1 2"); + add(checkBox1, "cell 1 3"); //---- checkBox2 ---- checkBox2.setText("disabled"); checkBox2.setEnabled(false); checkBox2.setMnemonic('D'); - add(checkBox2, "cell 2 2"); + add(checkBox2, "cell 2 3"); //---- checkBox3 ---- checkBox3.setText("selected"); checkBox3.setSelected(true); - add(checkBox3, "cell 3 2"); + add(checkBox3, "cell 3 3"); //---- checkBox4 ---- checkBox4.setText("selected disabled"); checkBox4.setSelected(true); checkBox4.setEnabled(false); - add(checkBox4, "cell 4 2"); + add(checkBox4, "cell 4 3"); //---- radioButtonLabel ---- radioButtonLabel.setText("JRadioButton:"); - add(radioButtonLabel, "cell 0 3"); + add(radioButtonLabel, "cell 0 4"); //---- radioButton1 ---- radioButton1.setText("enabled"); radioButton1.setMnemonic('N'); - add(radioButton1, "cell 1 3"); + add(radioButton1, "cell 1 4"); //---- radioButton2 ---- radioButton2.setText("disabled"); radioButton2.setEnabled(false); radioButton2.setMnemonic('S'); - add(radioButton2, "cell 2 3"); + add(radioButton2, "cell 2 4"); //---- radioButton3 ---- radioButton3.setText("selected"); radioButton3.setSelected(true); - add(radioButton3, "cell 3 3"); + add(radioButton3, "cell 3 4"); //---- radioButton4 ---- radioButton4.setText("selected disabled"); radioButton4.setSelected(true); radioButton4.setEnabled(false); - add(radioButton4, "cell 4 3"); + add(radioButton4, "cell 4 4"); //---- comboBoxLabel ---- comboBoxLabel.setText("JComboBox:"); - add(comboBoxLabel, "cell 0 4"); + add(comboBoxLabel, "cell 0 5"); //---- comboBox1 ---- comboBox1.setEditable(true); @@ -287,7 +317,7 @@ public class FlatComponentsTest "bb", "ccc" })); - add(comboBox1, "cell 1 4,growx"); + add(comboBox1, "cell 1 5,growx"); //---- comboBox2 ---- comboBox2.setEditable(true); @@ -298,7 +328,7 @@ public class FlatComponentsTest "bb", "ccc" })); - add(comboBox2, "cell 2 4,growx"); + add(comboBox2, "cell 2 5,growx"); //---- comboBox3 ---- comboBox3.setModel(new DefaultComboBoxModel<>(new String[] { @@ -307,7 +337,7 @@ public class FlatComponentsTest "bb", "ccc" })); - add(comboBox3, "cell 3 4,growx"); + add(comboBox3, "cell 3 5,growx"); //---- comboBox4 ---- comboBox4.setModel(new DefaultComboBoxModel<>(new String[] { @@ -317,92 +347,92 @@ public class FlatComponentsTest "ccc" })); comboBox4.setEnabled(false); - add(comboBox4, "cell 4 4,growx"); + add(comboBox4, "cell 4 5,growx"); //---- spinnerLabel ---- spinnerLabel.setText("JSpinner:"); - add(spinnerLabel, "cell 0 5"); - add(spinner1, "cell 1 5,growx"); + add(spinnerLabel, "cell 0 6"); + add(spinner1, "cell 1 6,growx"); //---- spinner2 ---- spinner2.setEnabled(false); - add(spinner2, "cell 2 5,growx"); + add(spinner2, "cell 2 6,growx"); //---- textFieldLabel ---- textFieldLabel.setText("JTextField:"); - add(textFieldLabel, "cell 0 6"); + add(textFieldLabel, "cell 0 7"); //---- textField1 ---- textField1.setText("editable"); - add(textField1, "cell 1 6,growx"); + add(textField1, "cell 1 7,growx"); //---- textField2 ---- textField2.setText("disabled"); textField2.setEnabled(false); - add(textField2, "cell 2 6,growx"); + add(textField2, "cell 2 7,growx"); //---- textField3 ---- textField3.setText("not editable"); textField3.setEditable(false); - add(textField3, "cell 3 6,growx"); + add(textField3, "cell 3 7,growx"); //---- textField4 ---- textField4.setText("not editable disabled"); textField4.setEnabled(false); textField4.setEditable(false); - add(textField4, "cell 4 6,growx"); + add(textField4, "cell 4 7,growx"); //---- formattedTextFieldLabel ---- formattedTextFieldLabel.setText("JFormattedTextField:"); - add(formattedTextFieldLabel, "cell 0 7"); + add(formattedTextFieldLabel, "cell 0 8"); //---- formattedTextField1 ---- formattedTextField1.setText("editable"); - add(formattedTextField1, "cell 1 7,growx"); + add(formattedTextField1, "cell 1 8,growx"); //---- formattedTextField2 ---- formattedTextField2.setText("disabled"); formattedTextField2.setEnabled(false); - add(formattedTextField2, "cell 2 7,growx"); + add(formattedTextField2, "cell 2 8,growx"); //---- formattedTextField3 ---- formattedTextField3.setText("not editable"); formattedTextField3.setEditable(false); - add(formattedTextField3, "cell 3 7,growx"); + add(formattedTextField3, "cell 3 8,growx"); //---- formattedTextField4 ---- formattedTextField4.setText("not editable disabled"); formattedTextField4.setEnabled(false); formattedTextField4.setEditable(false); - add(formattedTextField4, "cell 4 7,growx"); + add(formattedTextField4, "cell 4 8,growx"); //---- passwordFieldLabel ---- passwordFieldLabel.setText("JPasswordField:"); - add(passwordFieldLabel, "cell 0 8"); + add(passwordFieldLabel, "cell 0 9"); //---- passwordField1 ---- passwordField1.setText("editable"); - add(passwordField1, "cell 1 8,growx"); + add(passwordField1, "cell 1 9,growx"); //---- passwordField2 ---- passwordField2.setText("disabled"); passwordField2.setEnabled(false); - add(passwordField2, "cell 2 8,growx"); + add(passwordField2, "cell 2 9,growx"); //---- passwordField3 ---- passwordField3.setText("not editable"); passwordField3.setEditable(false); - add(passwordField3, "cell 3 8,growx"); + add(passwordField3, "cell 3 9,growx"); //---- passwordField4 ---- passwordField4.setText("not editable disabled"); passwordField4.setEnabled(false); passwordField4.setEditable(false); - add(passwordField4, "cell 4 8,growx"); + add(passwordField4, "cell 4 9,growx"); //---- textAreaLabel ---- textAreaLabel.setText("JTextArea:"); - add(textAreaLabel, "cell 0 9"); + add(textAreaLabel, "cell 0 10"); //======== scrollPane1 ======== { @@ -414,7 +444,7 @@ public class FlatComponentsTest textArea1.setRows(2); scrollPane1.setViewportView(textArea1); } - add(scrollPane1, "cell 1 9,growx"); + add(scrollPane1, "cell 1 10,growx"); //======== scrollPane2 ======== { @@ -427,7 +457,7 @@ public class FlatComponentsTest textArea2.setEnabled(false); scrollPane2.setViewportView(textArea2); } - add(scrollPane2, "cell 2 9,growx"); + add(scrollPane2, "cell 2 10,growx"); //======== scrollPane3 ======== { @@ -440,7 +470,7 @@ public class FlatComponentsTest textArea3.setEditable(false); scrollPane3.setViewportView(textArea3); } - add(scrollPane3, "cell 3 9,growx"); + add(scrollPane3, "cell 3 10,growx"); //======== scrollPane4 ======== { @@ -454,16 +484,16 @@ public class FlatComponentsTest textArea4.setEnabled(false); scrollPane4.setViewportView(textArea4); } - add(scrollPane4, "cell 4 9,growx"); + add(scrollPane4, "cell 4 10,growx"); //---- textArea5 ---- textArea5.setRows(2); textArea5.setText("no scroll pane"); - add(textArea5, "cell 5 9,growx"); + add(textArea5, "cell 5 10,growx"); //---- editorPaneLabel ---- editorPaneLabel.setText("JEditorPane"); - add(editorPaneLabel, "cell 0 10"); + add(editorPaneLabel, "cell 0 11"); //======== scrollPane5 ======== { @@ -474,7 +504,7 @@ public class FlatComponentsTest editorPane1.setText("editable"); scrollPane5.setViewportView(editorPane1); } - add(scrollPane5, "cell 1 10,growx"); + add(scrollPane5, "cell 1 11,growx"); //======== scrollPane6 ======== { @@ -486,7 +516,7 @@ public class FlatComponentsTest editorPane2.setEnabled(false); scrollPane6.setViewportView(editorPane2); } - add(scrollPane6, "cell 2 10,growx"); + add(scrollPane6, "cell 2 11,growx"); //======== scrollPane7 ======== { @@ -498,7 +528,7 @@ public class FlatComponentsTest editorPane3.setEditable(false); scrollPane7.setViewportView(editorPane3); } - add(scrollPane7, "cell 3 10,growx"); + add(scrollPane7, "cell 3 11,growx"); //======== scrollPane8 ======== { @@ -511,15 +541,15 @@ public class FlatComponentsTest editorPane4.setEnabled(false); scrollPane8.setViewportView(editorPane4); } - add(scrollPane8, "cell 4 10,growx"); + add(scrollPane8, "cell 4 11,growx"); //---- editorPane5 ---- editorPane5.setText("no scroll pane"); - add(editorPane5, "cell 5 10,growx"); + add(editorPane5, "cell 5 11,growx"); //---- textPaneLabel ---- textPaneLabel.setText("JTextPane:"); - add(textPaneLabel, "cell 0 11"); + add(textPaneLabel, "cell 0 12"); //======== scrollPane9 ======== { @@ -530,7 +560,7 @@ public class FlatComponentsTest textPane1.setText("editable"); scrollPane9.setViewportView(textPane1); } - add(scrollPane9, "cell 1 11,growx"); + add(scrollPane9, "cell 1 12,growx"); //======== scrollPane10 ======== { @@ -542,7 +572,7 @@ public class FlatComponentsTest textPane2.setEnabled(false); scrollPane10.setViewportView(textPane2); } - add(scrollPane10, "cell 2 11,growx"); + add(scrollPane10, "cell 2 12,growx"); //======== scrollPane11 ======== { @@ -554,7 +584,7 @@ public class FlatComponentsTest textPane3.setEditable(false); scrollPane11.setViewportView(textPane3); } - add(scrollPane11, "cell 3 11,growx"); + add(scrollPane11, "cell 3 12,growx"); //======== scrollPane12 ======== { @@ -567,15 +597,15 @@ public class FlatComponentsTest textPane4.setEnabled(false); scrollPane12.setViewportView(textPane4); } - add(scrollPane12, "cell 4 11,growx"); + add(scrollPane12, "cell 4 12,growx"); //---- textPane5 ---- textPane5.setText("no scroll pane"); - add(textPane5, "cell 5 11,growx"); + add(textPane5, "cell 5 12,growx"); //---- scrollPaneLabel ---- scrollPaneLabel.setText("JScrollPane:"); - add(scrollPaneLabel, "cell 0 12"); + add(scrollPaneLabel, "cell 0 13"); //======== scrollPane13 ======== { @@ -589,21 +619,21 @@ public class FlatComponentsTest } scrollPane13.setViewportView(panel1); } - add(scrollPane13, "cell 1 12,grow,width 70,height 70"); - add(scrollBar2, "cell 2 12 1 4,growy"); + add(scrollPane13, "cell 1 13,grow,width 70,height 70"); + add(scrollBar2, "cell 2 13 1 4,growy"); //---- scrollBar3 ---- scrollBar3.setEnabled(false); - add(scrollBar3, "cell 2 12 1 4,growy"); + add(scrollBar3, "cell 2 13 1 4,growy"); //---- separator2 ---- separator2.setOrientation(SwingConstants.VERTICAL); - add(separator2, "cell 2 12 1 4,growy"); + add(separator2, "cell 2 13 1 4,growy"); //---- slider2 ---- slider2.setOrientation(SwingConstants.VERTICAL); slider2.setValue(30); - add(slider2, "cell 2 12 1 4,growy"); + add(slider2, "cell 2 13 1 4,growy"); //---- slider4 ---- slider4.setMinorTickSpacing(10); @@ -612,19 +642,19 @@ public class FlatComponentsTest slider4.setPaintLabels(true); slider4.setOrientation(SwingConstants.VERTICAL); slider4.setValue(30); - add(slider4, "cell 2 12 1 4,growy"); - add(scrollPane14, "cell 3 12,grow"); + add(slider4, "cell 2 13 1 4,growy"); + add(scrollPane14, "cell 3 13,grow"); //---- progressBar3 ---- progressBar3.setOrientation(SwingConstants.VERTICAL); progressBar3.setValue(50); - add(progressBar3, "cell 4 12 1 4,growy"); + add(progressBar3, "cell 4 13 1 4,growy"); //---- progressBar4 ---- progressBar4.setOrientation(SwingConstants.VERTICAL); progressBar4.setValue(55); progressBar4.setStringPainted(true); - add(progressBar4, "cell 4 12 1 4,growy"); + add(progressBar4, "cell 4 13 1 4,growy"); //======== toolBar2 ======== { @@ -647,38 +677,38 @@ public class FlatComponentsTest toggleButton7.setIcon(UIManager.getIcon("Tree.closedIcon")); toolBar2.add(toggleButton7); } - add(toolBar2, "cell 4 12 1 4,growy"); + add(toolBar2, "cell 4 13 1 4,growy"); //---- scrollBarLabel ---- scrollBarLabel.setText("JScrollBar:"); - add(scrollBarLabel, "cell 0 13"); + add(scrollBarLabel, "cell 0 14"); //---- scrollBar1 ---- scrollBar1.setOrientation(Adjustable.HORIZONTAL); - add(scrollBar1, "cell 1 13,growx"); + add(scrollBar1, "cell 1 14,growx"); //---- scrollBar4 ---- scrollBar4.setOrientation(Adjustable.HORIZONTAL); scrollBar4.setEnabled(false); - add(scrollBar4, "cell 1 14,growx"); + add(scrollBar4, "cell 1 15,growx"); //---- separatorLabel ---- separatorLabel.setText("JSeparator:"); - add(separatorLabel, "cell 0 15"); - add(separator1, "cell 1 15,growx"); + add(separatorLabel, "cell 0 16"); + add(separator1, "cell 1 16,growx"); //---- sliderLabel ---- sliderLabel.setText("JSlider:"); - add(sliderLabel, "cell 0 16"); + add(sliderLabel, "cell 0 17"); //---- slider1 ---- slider1.setValue(30); - add(slider1, "cell 1 16 3 1,aligny top,grow 100 0"); + add(slider1, "cell 1 17 3 1,aligny top,grow 100 0"); //---- slider6 ---- slider6.setEnabled(false); slider6.setValue(30); - add(slider6, "cell 1 16 3 1,aligny top,growy 0"); + add(slider6, "cell 1 17 3 1,aligny top,growy 0"); //---- slider3 ---- slider3.setMinorTickSpacing(10); @@ -686,7 +716,7 @@ public class FlatComponentsTest slider3.setMajorTickSpacing(50); slider3.setPaintLabels(true); slider3.setValue(30); - add(slider3, "cell 1 17 3 1,aligny top,grow 100 0"); + add(slider3, "cell 1 18 3 1,aligny top,grow 100 0"); //---- slider5 ---- slider5.setMinorTickSpacing(10); @@ -695,37 +725,37 @@ public class FlatComponentsTest slider5.setPaintLabels(true); slider5.setEnabled(false); slider5.setValue(30); - add(slider5, "cell 1 17 3 1,aligny top,growy 0"); + add(slider5, "cell 1 18 3 1,aligny top,growy 0"); //---- progressBarLabel ---- progressBarLabel.setText("JProgressBar:"); - add(progressBarLabel, "cell 0 18"); + add(progressBarLabel, "cell 0 19"); //---- progressBar1 ---- progressBar1.setValue(50); - add(progressBar1, "cell 1 18 3 1,growx"); + add(progressBar1, "cell 1 19 3 1,growx"); //---- progressBar2 ---- progressBar2.setStringPainted(true); progressBar2.setValue(55); - add(progressBar2, "cell 1 18 3 1,growx"); + add(progressBar2, "cell 1 19 3 1,growx"); //---- indeterminateCheckBox ---- indeterminateCheckBox.setText("indeterminate"); indeterminateCheckBox.addActionListener(e -> indeterminateCheckBoxActionPerformed()); - add(indeterminateCheckBox, "cell 4 18"); + add(indeterminateCheckBox, "cell 4 19"); //---- toolTipLabel ---- toolTipLabel.setText("JToolTip:"); - add(toolTipLabel, "cell 0 19"); + add(toolTipLabel, "cell 0 20"); //---- toolTip1 ---- toolTip1.setTipText("Some text in tool tip."); - add(toolTip1, "cell 1 19 3 1"); + add(toolTip1, "cell 1 20 3 1"); //---- toolBarLabel ---- toolBarLabel.setText("JToolBar:"); - add(toolBarLabel, "cell 0 20"); + add(toolBarLabel, "cell 0 21"); //======== toolBar1 ======== { @@ -752,9 +782,10 @@ public class FlatComponentsTest //---- toggleButton6 ---- toggleButton6.setText("Toggle"); toggleButton6.setIcon(UIManager.getIcon("Tree.leafIcon")); + toggleButton6.setSelected(true); toolBar1.add(toggleButton6); } - add(toolBar1, "cell 1 20 3 1,growx"); + add(toolBar1, "cell 1 21 3 1,growx"); // JFormDesigner - End of component initialization //GEN-END:initComponents } diff --git a/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatComponentsTest.jfd b/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatComponentsTest.jfd index 387984ae..c0051bc2 100644 --- a/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatComponentsTest.jfd +++ b/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatComponentsTest.jfd @@ -9,7 +9,7 @@ new FormModel { add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets 0,hidemode 3,gap 5 5,ltr" "$columnConstraints": "[][][][][][]" - "$rowConstraints": "[][][][][][][][][][][][][][][][][][][][][]" + "$rowConstraints": "[][][][][][][][][][][][][][][][][][][][][][]" } ) { name: "this" add( new FormComponent( "javax.swing.JLabel" ) { @@ -61,18 +61,52 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 3 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 2" + "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 2" + "value": "cell 1 3" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "checkBox2" @@ -80,14 +114,14 @@ new FormModel { "enabled": false "mnemonic": 68 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 2" + "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 2" + "value": "cell 3 3" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "checkBox4" @@ -95,20 +129,20 @@ new FormModel { "selected": true "enabled": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 2" + "value": "cell 4 3" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "radioButtonLabel" "text": "JRadioButton:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 3" + "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 3" + "value": "cell 1 4" } ) add( new FormComponent( "javax.swing.JRadioButton" ) { name: "radioButton2" @@ -116,14 +150,14 @@ new FormModel { "enabled": false "mnemonic": 83 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 3" + "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 3" + "value": "cell 3 4" } ) add( new FormComponent( "javax.swing.JRadioButton" ) { name: "radioButton4" @@ -131,13 +165,13 @@ new FormModel { "selected": true "enabled": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 3" + "value": "cell 4 4" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "comboBoxLabel" "text": "JComboBox:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 4" + "value": "cell 0 5" } ) add( new FormComponent( "javax.swing.JComboBox" ) { name: "comboBox1" @@ -150,7 +184,7 @@ new FormModel { addElement( "ccc" ) } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 4,growx" + "value": "cell 1 5,growx" } ) add( new FormComponent( "javax.swing.JComboBox" ) { name: "comboBox2" @@ -164,7 +198,7 @@ new FormModel { addElement( "ccc" ) } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 4,growx" + "value": "cell 2 5,growx" } ) add( new FormComponent( "javax.swing.JComboBox" ) { name: "comboBox3" @@ -176,7 +210,7 @@ new FormModel { addElement( "ccc" ) } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 4,growx" + "value": "cell 3 5,growx" } ) add( new FormComponent( "javax.swing.JComboBox" ) { name: "comboBox4" @@ -189,50 +223,50 @@ new FormModel { } "enabled": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 4,growx" + "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 5" + "value": "cell 0 6" } ) add( new FormComponent( "javax.swing.JSpinner" ) { name: "spinner1" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 5,growx" + "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 5,growx" + "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 6" + "value": "cell 0 7" } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "textField1" "text": "editable" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 6,growx" + "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 6,growx" + "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 6,growx" + "value": "cell 3 7,growx" } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "textField4" @@ -240,33 +274,33 @@ new FormModel { "enabled": false "editable": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 6,growx" + "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 7" + "value": "cell 0 8" } ) add( new FormComponent( "javax.swing.JFormattedTextField" ) { name: "formattedTextField1" "text": "editable" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 7,growx" + "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 7,growx" + "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 7,growx" + "value": "cell 3 8,growx" } ) add( new FormComponent( "javax.swing.JFormattedTextField" ) { name: "formattedTextField4" @@ -274,33 +308,33 @@ new FormModel { "enabled": false "editable": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 7,growx" + "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 8" + "value": "cell 0 9" } ) add( new FormComponent( "javax.swing.JPasswordField" ) { name: "passwordField1" "text": "editable" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 8,growx" + "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 8,growx" + "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 8,growx" + "value": "cell 3 9,growx" } ) add( new FormComponent( "javax.swing.JPasswordField" ) { name: "passwordField4" @@ -308,13 +342,13 @@ new FormModel { "enabled": false "editable": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 8,growx" + "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 9" + "value": "cell 0 10" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane1" @@ -326,7 +360,7 @@ new FormModel { "rows": 2 } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 9,growx" + "value": "cell 1 10,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane2" @@ -339,7 +373,7 @@ new FormModel { "enabled": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 9,growx" + "value": "cell 2 10,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane3" @@ -352,7 +386,7 @@ new FormModel { "editable": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 9,growx" + "value": "cell 3 10,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane4" @@ -366,20 +400,20 @@ new FormModel { "enabled": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 9,growx" + "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 9,growx" + "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 10" + "value": "cell 0 11" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane5" @@ -390,7 +424,7 @@ new FormModel { "text": "editable" } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 10,growx" + "value": "cell 1 11,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane6" @@ -402,7 +436,7 @@ new FormModel { "enabled": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 10,growx" + "value": "cell 2 11,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane7" @@ -414,7 +448,7 @@ new FormModel { "editable": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 10,growx" + "value": "cell 3 11,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane8" @@ -427,19 +461,19 @@ new FormModel { "enabled": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 10,growx" + "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 10,growx" + "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 11" + "value": "cell 0 12" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane9" @@ -450,7 +484,7 @@ new FormModel { "text": "editable" } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 11,growx" + "value": "cell 1 12,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane10" @@ -462,7 +496,7 @@ new FormModel { "enabled": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 11,growx" + "value": "cell 2 12,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane11" @@ -474,7 +508,7 @@ new FormModel { "editable": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 11,growx" + "value": "cell 3 12,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane12" @@ -487,19 +521,19 @@ new FormModel { "enabled": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 11,growx" + "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 11,growx" + "value": "cell 5 12,growx" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "scrollPaneLabel" "text": "JScrollPane:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 12" + "value": "cell 0 13" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane13" @@ -510,31 +544,31 @@ new FormModel { "preferredSize": new java.awt.Dimension( 200, 200 ) } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 12,grow,width 70,height 70" + "value": "cell 1 13,grow,width 70,height 70" } ) add( new FormComponent( "javax.swing.JScrollBar" ) { name: "scrollBar2" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 12 1 4,growy" + "value": "cell 2 13 1 4,growy" } ) add( new FormComponent( "javax.swing.JScrollBar" ) { name: "scrollBar3" "enabled": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 12 1 4,growy" + "value": "cell 2 13 1 4,growy" } ) add( new FormComponent( "javax.swing.JSeparator" ) { name: "separator2" "orientation": 1 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 12 1 4,growy" + "value": "cell 2 13 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 12 1 4,growy" + "value": "cell 2 13 1 4,growy" } ) add( new FormComponent( "javax.swing.JSlider" ) { name: "slider4" @@ -545,12 +579,12 @@ new FormModel { "orientation": 1 "value": 30 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 12 1 4,growy" + "value": "cell 2 13 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 12,grow" + "value": "cell 3 13,grow" } ) add( new FormComponent( "javax.swing.JProgressBar" ) { name: "progressBar3" @@ -560,7 +594,7 @@ new FormModel { "JavaCodeGenerator.variableLocal": false } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 12 1 4,growy" + "value": "cell 4 13 1 4,growy" } ) add( new FormComponent( "javax.swing.JProgressBar" ) { name: "progressBar4" @@ -571,7 +605,7 @@ new FormModel { "JavaCodeGenerator.variableLocal": false } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 12 1 4,growy" + "value": "cell 4 13 1 4,growy" } ) add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { name: "toolBar2" @@ -596,56 +630,56 @@ new FormModel { "icon": new com.jformdesigner.model.SwingIcon( 2, "Tree.closedIcon" ) } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 12 1 4,growy" + "value": "cell 4 13 1 4,growy" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "scrollBarLabel" "text": "JScrollBar:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 13" + "value": "cell 0 14" } ) add( new FormComponent( "javax.swing.JScrollBar" ) { name: "scrollBar1" "orientation": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 13,growx" + "value": "cell 1 14,growx" } ) add( new FormComponent( "javax.swing.JScrollBar" ) { name: "scrollBar4" "orientation": 0 "enabled": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 14,growx" + "value": "cell 1 15,growx" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "separatorLabel" "text": "JSeparator:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 15" + "value": "cell 0 16" } ) add( new FormComponent( "javax.swing.JSeparator" ) { name: "separator1" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 15,growx" + "value": "cell 1 16,growx" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "sliderLabel" "text": "JSlider:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 16" + "value": "cell 0 17" } ) add( new FormComponent( "javax.swing.JSlider" ) { name: "slider1" "value": 30 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 16 3 1,aligny top,grow 100 0" + "value": "cell 1 17 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 16 3 1,aligny top,growy 0" + "value": "cell 1 17 3 1,aligny top,growy 0" } ) add( new FormComponent( "javax.swing.JSlider" ) { name: "slider3" @@ -655,7 +689,7 @@ new FormModel { "paintLabels": true "value": 30 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 17 3 1,aligny top,grow 100 0" + "value": "cell 1 18 3 1,aligny top,grow 100 0" } ) add( new FormComponent( "javax.swing.JSlider" ) { name: "slider5" @@ -666,13 +700,13 @@ new FormModel { "enabled": false "value": 30 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 17 3 1,aligny top,growy 0" + "value": "cell 1 18 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 18" + "value": "cell 0 19" } ) add( new FormComponent( "javax.swing.JProgressBar" ) { name: "progressBar1" @@ -681,7 +715,7 @@ new FormModel { "JavaCodeGenerator.variableLocal": false } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 18 3 1,growx" + "value": "cell 1 19 3 1,growx" } ) add( new FormComponent( "javax.swing.JProgressBar" ) { name: "progressBar2" @@ -691,7 +725,7 @@ new FormModel { "JavaCodeGenerator.variableLocal": false } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 18 3 1,growx" + "value": "cell 1 19 3 1,growx" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "indeterminateCheckBox" @@ -701,25 +735,25 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "indeterminateCheckBoxActionPerformed", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 18" + "value": "cell 4 19" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "toolTipLabel" "text": "JToolTip:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 19" + "value": "cell 0 20" } ) add( new FormComponent( "javax.swing.JToolTip" ) { name: "toolTip1" "tipText": "Some text in tool tip." }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 19 3 1" + "value": "cell 1 20 3 1" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "toolBarLabel" "text": "JToolBar:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 20" + "value": "cell 0 21" } ) add( new FormContainer( "javax.swing.JToolBar", new FormLayoutManager( class javax.swing.JToolBar ) ) { name: "toolBar1" @@ -750,9 +784,10 @@ new FormModel { 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 20 3 1,growx" + "value": "cell 1 21 3 1,growx" } ) }, new FormLayoutConstraints( null ) { "location": new java.awt.Point( 0, 0 ) diff --git a/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties b/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties index 148f8d9e..8c785457 100644 --- a/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties +++ b/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties @@ -200,6 +200,14 @@ TableHeader.separatorColor=00ff00 TableHeader.bottomSeparatorColor=00ff00 +#---- ToggleButton ---- + +ToggleButton.background=ddddff +ToggleButton.selectedBackground=44ff44 +ToggleButton.selectedForeground=000000 +ToggleButton.disabledSelectedBackground=44dd44 + + #---- ToolTip ---- ToolTip.background=eeeeff