diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.java index 301be31c..b57204f1 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.java @@ -521,26 +521,27 @@ public class FlatContainerTest htmlTabsCheckBox = new JCheckBox(); multiLineTabsCheckBox = new JCheckBox(); JLabel tabsPopupPolicyLabel = new JLabel(); - tabsPopupPolicyField = new FlatTestEnumComboBox<>(); + tabsPopupPolicyField = new FlatTestEnumSelector<>(); tabBackForegroundCheckBox = new JCheckBox(); JLabel scrollButtonsPolicyLabel = new JLabel(); - scrollButtonsPolicyField = new FlatTestEnumComboBox<>(); + scrollButtonsPolicyField = new FlatTestEnumSelector<>(); tabIconsCheckBox = new JCheckBox(); tabIconSizeSpinner = new JSpinner(); - iconPlacementField = new FlatTestEnumComboBox<>(); + iconPlacementField = new FlatTestEnumSelector<>(); JLabel scrollButtonsPlacementLabel = new JLabel(); - scrollButtonsPlacementField = new FlatTestEnumComboBox<>(); + scrollButtonsPlacementField = new FlatTestEnumSelector<>(); tabsClosableCheckBox = new JCheckBox(); JLabel tabPlacementLabel = new JLabel(); - tabPlacementField = new FlatTestEnumComboBox<>(); + tabPlacementField = new FlatTestEnumSelector<>(); secondTabClosableCheckBox = new FlatTriStateCheckBox(); JLabel tabAreaAlignmentLabel = new JLabel(); - tabAreaAlignmentField = new FlatTestEnumComboBox<>(); - tabAlignmentField = new FlatTestEnumComboBox<>(); + tabAreaAlignmentField = new FlatTestEnumSelector<>(); JLabel tabWidthModeLabel = new JLabel(); - tabWidthModeField = new FlatTestEnumComboBox<>(); + tabWidthModeField = new FlatTestEnumSelector<>(); + JLabel tabAlignmentLabel = new JLabel(); + tabAlignmentField = new FlatTestEnumSelector<>(); JLabel tabTypeLabel = new JLabel(); - tabTypeComboBox = new FlatTestEnumComboBox<>(); + tabTypeComboBox = new FlatTestEnumSelector<>(); leadingComponentCheckBox = new JCheckBox(); customBorderCheckBox = new JCheckBox(); tabAreaInsetsCheckBox = new JCheckBox(); @@ -663,7 +664,8 @@ public class FlatContainerTest "insets 0,hidemode 3", // columns "[]" + - "[fill]" + + "[]" + + "[]" + "[]", // rows "[center]" + @@ -672,6 +674,7 @@ public class FlatContainerTest "[]" + "[]" + "[]" + + "[]" + "[]para" + "[]" + "[]para" + @@ -693,22 +696,22 @@ public class FlatContainerTest //---- tabCountSpinner ---- tabCountSpinner.setModel(new SpinnerNumberModel(4, 0, null, 1)); tabCountSpinner.addChangeListener(e -> tabCountChanged()); - tabbedPaneControlPanel.add(tabCountSpinner, "cell 1 0"); + tabbedPaneControlPanel.add(tabCountSpinner, "cell 1 0,width 80"); //---- customTabsCheckBox ---- customTabsCheckBox.setText("Custom tabs"); customTabsCheckBox.addActionListener(e -> customTabsChanged()); - tabbedPaneControlPanel.add(customTabsCheckBox, "cell 2 0"); + tabbedPaneControlPanel.add(customTabsCheckBox, "cell 2 0 2 1"); //---- htmlTabsCheckBox ---- htmlTabsCheckBox.setText("HTML"); htmlTabsCheckBox.addActionListener(e -> htmlTabsChanged()); - tabbedPaneControlPanel.add(htmlTabsCheckBox, "cell 2 0"); + tabbedPaneControlPanel.add(htmlTabsCheckBox, "cell 2 0 2 1"); //---- multiLineTabsCheckBox ---- multiLineTabsCheckBox.setText("multi-line"); multiLineTabsCheckBox.addActionListener(e -> htmlTabsChanged()); - tabbedPaneControlPanel.add(multiLineTabsCheckBox, "cell 2 0"); + tabbedPaneControlPanel.add(multiLineTabsCheckBox, "cell 2 0 2 1"); //---- tabsPopupPolicyLabel ---- tabsPopupPolicyLabel.setText("Tabs popup policy:"); @@ -721,7 +724,7 @@ public class FlatContainerTest //---- tabBackForegroundCheckBox ---- tabBackForegroundCheckBox.setText("Tab back/foreground"); tabBackForegroundCheckBox.addActionListener(e -> tabBackForegroundChanged()); - tabbedPaneControlPanel.add(tabBackForegroundCheckBox, "cell 2 1"); + tabbedPaneControlPanel.add(tabBackForegroundCheckBox, "cell 2 1 2 1"); //---- scrollButtonsPolicyLabel ---- scrollButtonsPolicyLabel.setText("Scroll buttons policy:"); @@ -734,18 +737,18 @@ public class FlatContainerTest //---- tabIconsCheckBox ---- tabIconsCheckBox.setText("Tab icons"); tabIconsCheckBox.addActionListener(e -> tabIconsChanged()); - tabbedPaneControlPanel.add(tabIconsCheckBox, "cell 2 2"); + tabbedPaneControlPanel.add(tabIconsCheckBox, "cell 2 2 2 1"); //---- tabIconSizeSpinner ---- tabIconSizeSpinner.setModel(new SpinnerListModel(new String[] {"16", "24", "32", "48", "64"})); tabIconSizeSpinner.setEnabled(false); tabIconSizeSpinner.addChangeListener(e -> tabIconsChanged()); - tabbedPaneControlPanel.add(tabIconSizeSpinner, "cell 2 2"); + tabbedPaneControlPanel.add(tabIconSizeSpinner, "cell 2 2 2 1"); //---- iconPlacementField ---- iconPlacementField.setEnabled(false); iconPlacementField.addActionListener(e -> iconPlacementChanged()); - tabbedPaneControlPanel.add(iconPlacementField, "cell 2 2"); + tabbedPaneControlPanel.add(iconPlacementField, "cell 2 2 2 1"); //---- scrollButtonsPlacementLabel ---- scrollButtonsPlacementLabel.setText("Scroll buttons placement:"); @@ -758,7 +761,7 @@ public class FlatContainerTest //---- tabsClosableCheckBox ---- tabsClosableCheckBox.setText("Tabs closable"); tabsClosableCheckBox.addActionListener(e -> tabsClosableChanged()); - tabbedPaneControlPanel.add(tabsClosableCheckBox, "cell 2 3"); + tabbedPaneControlPanel.add(tabsClosableCheckBox, "cell 2 3 2 1"); //---- tabPlacementLabel ---- tabPlacementLabel.setText("Tab placement:"); @@ -771,110 +774,114 @@ public class FlatContainerTest //---- secondTabClosableCheckBox ---- secondTabClosableCheckBox.setText("Second Tab closable"); secondTabClosableCheckBox.addActionListener(e -> secondTabClosableChanged()); - tabbedPaneControlPanel.add(secondTabClosableCheckBox, "cell 2 4"); + tabbedPaneControlPanel.add(secondTabClosableCheckBox, "cell 2 4 2 1"); //---- tabAreaAlignmentLabel ---- - tabAreaAlignmentLabel.setText("Tab area/title alignment:"); + tabAreaAlignmentLabel.setText("Tab area alignment:"); tabbedPaneControlPanel.add(tabAreaAlignmentLabel, "cell 0 5"); //---- tabAreaAlignmentField ---- tabAreaAlignmentField.addActionListener(e -> tabAreaAlignmentChanged()); tabbedPaneControlPanel.add(tabAreaAlignmentField, "cell 1 5"); - //---- tabAlignmentField ---- - tabAlignmentField.addActionListener(e -> tabAlignmentChanged()); - tabbedPaneControlPanel.add(tabAlignmentField, "cell 1 5"); - //---- tabWidthModeLabel ---- tabWidthModeLabel.setText("Tab width mode:"); tabbedPaneControlPanel.add(tabWidthModeLabel, "cell 2 5"); //---- tabWidthModeField ---- tabWidthModeField.addActionListener(e -> tabWidthModeChanged()); - tabbedPaneControlPanel.add(tabWidthModeField, "cell 2 5"); + tabbedPaneControlPanel.add(tabWidthModeField, "cell 3 5"); + + //---- tabAlignmentLabel ---- + tabAlignmentLabel.setText("Tab title alignment:"); + tabbedPaneControlPanel.add(tabAlignmentLabel, "cell 0 6"); + + //---- tabAlignmentField ---- + tabAlignmentField.addActionListener(e -> tabAlignmentChanged()); + tabbedPaneControlPanel.add(tabAlignmentField, "cell 1 6"); //---- tabTypeLabel ---- tabTypeLabel.setText("Tab type:"); - tabbedPaneControlPanel.add(tabTypeLabel, "cell 0 6"); + tabbedPaneControlPanel.add(tabTypeLabel, "cell 0 7"); //---- tabTypeComboBox ---- tabTypeComboBox.addActionListener(e -> tabTypeChanged()); - tabbedPaneControlPanel.add(tabTypeComboBox, "cell 1 6"); + tabbedPaneControlPanel.add(tabTypeComboBox, "cell 1 7"); //---- leadingComponentCheckBox ---- leadingComponentCheckBox.setText("Leading component"); leadingComponentCheckBox.addActionListener(e -> leadingComponentChanged()); - tabbedPaneControlPanel.add(leadingComponentCheckBox, "cell 0 7"); + tabbedPaneControlPanel.add(leadingComponentCheckBox, "cell 0 8"); //---- customBorderCheckBox ---- customBorderCheckBox.setText("Custom border"); customBorderCheckBox.addActionListener(e -> customBorderChanged()); - tabbedPaneControlPanel.add(customBorderCheckBox, "cell 1 7"); + tabbedPaneControlPanel.add(customBorderCheckBox, "cell 1 8"); //---- tabAreaInsetsCheckBox ---- tabAreaInsetsCheckBox.setText("Tab area insets (5,5,10,10)"); tabAreaInsetsCheckBox.addActionListener(e -> tabAreaInsetsChanged()); - tabbedPaneControlPanel.add(tabAreaInsetsCheckBox, "cell 2 7"); + tabbedPaneControlPanel.add(tabAreaInsetsCheckBox, "cell 2 8 2 1"); //---- trailingComponentCheckBox ---- trailingComponentCheckBox.setText("Trailing component"); trailingComponentCheckBox.addActionListener(e -> trailingComponentChanged()); - tabbedPaneControlPanel.add(trailingComponentCheckBox, "cell 0 8"); + tabbedPaneControlPanel.add(trailingComponentCheckBox, "cell 0 9"); //---- hasFullBorderCheckBox ---- hasFullBorderCheckBox.setText("Show content border"); hasFullBorderCheckBox.addActionListener(e -> hasFullBorderChanged()); - tabbedPaneControlPanel.add(hasFullBorderCheckBox, "cell 1 8,alignx left,growx 0"); + tabbedPaneControlPanel.add(hasFullBorderCheckBox, "cell 1 9,alignx left,growx 0"); //---- smallerTabHeightCheckBox ---- smallerTabHeightCheckBox.setText("Smaller tab height (26)"); smallerTabHeightCheckBox.addActionListener(e -> smallerTabHeightChanged()); - tabbedPaneControlPanel.add(smallerTabHeightCheckBox, "cell 2 8"); + tabbedPaneControlPanel.add(smallerTabHeightCheckBox, "cell 2 9 2 1"); //---- minimumTabWidthCheckBox ---- minimumTabWidthCheckBox.setText("Minimum tab width (100)"); minimumTabWidthCheckBox.addActionListener(e -> minimumTabWidthChanged()); - tabbedPaneControlPanel.add(minimumTabWidthCheckBox, "cell 0 9"); + tabbedPaneControlPanel.add(minimumTabWidthCheckBox, "cell 0 10"); //---- hideContentSeparatorCheckBox ---- hideContentSeparatorCheckBox.setText("Hide content separator"); hideContentSeparatorCheckBox.addActionListener(e -> hideContentSeparatorChanged()); - tabbedPaneControlPanel.add(hideContentSeparatorCheckBox, "cell 1 9"); + tabbedPaneControlPanel.add(hideContentSeparatorCheckBox, "cell 1 10"); //---- smallerInsetsCheckBox ---- smallerInsetsCheckBox.setText("Smaller tab insets (2,2,2,2)"); smallerInsetsCheckBox.addActionListener(e -> smallerInsetsChanged()); - tabbedPaneControlPanel.add(smallerInsetsCheckBox, "cell 2 9"); + tabbedPaneControlPanel.add(smallerInsetsCheckBox, "cell 2 10 2 1"); //---- maximumTabWidthCheckBox ---- maximumTabWidthCheckBox.setText("Maximum tab width (60)"); maximumTabWidthCheckBox.addActionListener(e -> maximumTabWidthChanged()); - tabbedPaneControlPanel.add(maximumTabWidthCheckBox, "cell 0 10"); + tabbedPaneControlPanel.add(maximumTabWidthCheckBox, "cell 0 11"); //---- showTabSeparatorsCheckBox ---- showTabSeparatorsCheckBox.setText("Show tab separators"); showTabSeparatorsCheckBox.addActionListener(e -> showTabSeparatorsChanged()); - tabbedPaneControlPanel.add(showTabSeparatorsCheckBox, "cell 1 10"); + tabbedPaneControlPanel.add(showTabSeparatorsCheckBox, "cell 1 11"); //---- secondTabWiderCheckBox ---- secondTabWiderCheckBox.setText("Second Tab insets wider (4,20,4,20)"); secondTabWiderCheckBox.addActionListener(e -> secondTabWiderChanged()); - tabbedPaneControlPanel.add(secondTabWiderCheckBox, "cell 2 10"); + tabbedPaneControlPanel.add(secondTabWiderCheckBox, "cell 2 11 2 1"); //---- hideTabAreaWithOneTabCheckBox ---- hideTabAreaWithOneTabCheckBox.setText("Hide tab area with one tab"); hideTabAreaWithOneTabCheckBox.addActionListener(e -> hideTabAreaWithOneTabChanged()); - tabbedPaneControlPanel.add(hideTabAreaWithOneTabCheckBox, "cell 1 11"); + tabbedPaneControlPanel.add(hideTabAreaWithOneTabCheckBox, "cell 1 12"); //---- customWheelScrollingCheckBox ---- customWheelScrollingCheckBox.setText("Custom wheel scrolling"); customWheelScrollingCheckBox.addActionListener(e -> customWheelScrollingChanged()); - tabbedPaneControlPanel.add(customWheelScrollingCheckBox, "cell 2 11"); + tabbedPaneControlPanel.add(customWheelScrollingCheckBox, "cell 2 12 2 1"); //---- contextMenuCheckBox ---- contextMenuCheckBox.setText("Context menu on tabs"); contextMenuCheckBox.addActionListener(e -> contextMenuChanged()); - tabbedPaneControlPanel.add(contextMenuCheckBox, "cell 2 12"); + tabbedPaneControlPanel.add(contextMenuCheckBox, "cell 2 13 2 1"); } panel9.add(tabbedPaneControlPanel, cc.xywh(1, 11, 3, 1)); } @@ -894,20 +901,20 @@ public class FlatContainerTest private JCheckBox customTabsCheckBox; private JCheckBox htmlTabsCheckBox; private JCheckBox multiLineTabsCheckBox; - private FlatTestEnumComboBox tabsPopupPolicyField; + private FlatTestEnumSelector tabsPopupPolicyField; private JCheckBox tabBackForegroundCheckBox; - private FlatTestEnumComboBox scrollButtonsPolicyField; + private FlatTestEnumSelector scrollButtonsPolicyField; private JCheckBox tabIconsCheckBox; private JSpinner tabIconSizeSpinner; - private FlatTestEnumComboBox iconPlacementField; - private FlatTestEnumComboBox scrollButtonsPlacementField; + private FlatTestEnumSelector iconPlacementField; + private FlatTestEnumSelector scrollButtonsPlacementField; private JCheckBox tabsClosableCheckBox; - private FlatTestEnumComboBox tabPlacementField; + private FlatTestEnumSelector tabPlacementField; private FlatTriStateCheckBox secondTabClosableCheckBox; - private FlatTestEnumComboBox tabAreaAlignmentField; - private FlatTestEnumComboBox tabAlignmentField; - private FlatTestEnumComboBox tabWidthModeField; - private FlatTestEnumComboBox tabTypeComboBox; + private FlatTestEnumSelector tabAreaAlignmentField; + private FlatTestEnumSelector tabWidthModeField; + private FlatTestEnumSelector tabAlignmentField; + private FlatTestEnumSelector tabTypeComboBox; private JCheckBox leadingComponentCheckBox; private JCheckBox customBorderCheckBox; private JCheckBox tabAreaInsetsCheckBox; diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.jfd index 05a8a2f5..caf2c1f4 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatContainerTest.jfd @@ -1,4 +1,4 @@ -JFDML JFormDesigner: "8.0.0.0.194" Java: "17.0.2" encoding: "UTF-8" +JFDML JFormDesigner: "8.2.0.0.331" Java: "21" encoding: "UTF-8" new FormModel { contentType: "form/swing" @@ -131,8 +131,8 @@ new FormModel { } ) add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestFrame$NoRightToLeftPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets 0,hidemode 3" - "$columnConstraints": "[][fill][]" - "$rowConstraints": "[center][][][][][][]para[][]para[][][][]" + "$columnConstraints": "[][][][]" + "$rowConstraints": "[center][][][][][][][]para[][]para[][][][]" } ) { name: "tabbedPaneControlPanel" "opaque": false @@ -165,7 +165,7 @@ new FormModel { } addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "tabCountChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 0" + "value": "cell 1 0,width 80" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "customTabsCheckBox" @@ -175,7 +175,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "customTabsChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 0" + "value": "cell 2 0 2 1" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "htmlTabsCheckBox" @@ -185,7 +185,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "htmlTabsChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 0" + "value": "cell 2 0 2 1" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "multiLineTabsCheckBox" @@ -195,7 +195,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "htmlTabsChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 0" + "value": "cell 2 0 2 1" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "tabsPopupPolicyLabel" @@ -203,7 +203,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 1" } ) - add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) { name: "tabsPopupPolicyField" auxiliary() { "JavaCodeGenerator.variableLocal": false @@ -221,7 +221,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabBackForegroundChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 1" + "value": "cell 2 1 2 1" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "scrollButtonsPolicyLabel" @@ -229,7 +229,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 2" } ) - add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) { name: "scrollButtonsPolicyField" auxiliary() { "JavaCodeGenerator.variableLocal": false @@ -247,7 +247,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabIconsChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 2" + "value": "cell 2 2 2 1" } ) add( new FormComponent( "javax.swing.JSpinner" ) { name: "tabIconSizeSpinner" @@ -266,9 +266,9 @@ new FormModel { } addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "tabIconsChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 2" + "value": "cell 2 2 2 1" } ) - add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) { name: "iconPlacementField" "enabled": false auxiliary() { @@ -277,7 +277,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "iconPlacementChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 2" + "value": "cell 2 2 2 1" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "scrollButtonsPlacementLabel" @@ -285,7 +285,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 3" } ) - add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) { name: "scrollButtonsPlacementField" auxiliary() { "JavaCodeGenerator.variableLocal": false @@ -303,7 +303,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabsClosableChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 3" + "value": "cell 2 3 2 1" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "tabPlacementLabel" @@ -311,7 +311,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 4" } ) - add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) { name: "tabPlacementField" auxiliary() { "JavaCodeGenerator.variableLocal": false @@ -329,15 +329,15 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "secondTabClosableChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 4" + "value": "cell 2 4 2 1" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "tabAreaAlignmentLabel" - "text": "Tab area/title alignment:" + "text": "Tab area alignment:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 5" } ) - add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) { name: "tabAreaAlignmentField" auxiliary() { "JavaCodeGenerator.variableLocal": false @@ -347,23 +347,13 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 5" } ) - add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) { - name: "tabAlignmentField" - auxiliary() { - "JavaCodeGenerator.variableLocal": false - "JavaCodeGenerator.typeParameters": "TabAlignment" - } - addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAlignmentChanged", false ) ) - }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 5" - } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "tabWidthModeLabel" "text": "Tab width mode:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 2 5" } ) - add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) { name: "tabWidthModeField" auxiliary() { "JavaCodeGenerator.variableLocal": false @@ -371,15 +361,31 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabWidthModeChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 5" + "value": "cell 3 5" + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "tabAlignmentLabel" + "text": "Tab title alignment:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 6" + } ) + add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) { + name: "tabAlignmentField" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + "JavaCodeGenerator.typeParameters": "TabAlignment" + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAlignmentChanged", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 6" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "tabTypeLabel" "text": "Tab type:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 6" + "value": "cell 0 7" } ) - add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) { name: "tabTypeComboBox" auxiliary() { "JavaCodeGenerator.typeParameters": "TabType" @@ -387,7 +393,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabTypeChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 6" + "value": "cell 1 7" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "leadingComponentCheckBox" @@ -397,7 +403,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "leadingComponentChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 7" + "value": "cell 0 8" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "customBorderCheckBox" @@ -407,7 +413,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "customBorderChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 7" + "value": "cell 1 8" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "tabAreaInsetsCheckBox" @@ -417,7 +423,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "tabAreaInsetsChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 7" + "value": "cell 2 8 2 1" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "trailingComponentCheckBox" @@ -427,7 +433,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "trailingComponentChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 8" + "value": "cell 0 9" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "hasFullBorderCheckBox" @@ -437,7 +443,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hasFullBorderChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 8,alignx left,growx 0" + "value": "cell 1 9,alignx left,growx 0" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "smallerTabHeightCheckBox" @@ -447,7 +453,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "smallerTabHeightChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 8" + "value": "cell 2 9 2 1" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "minimumTabWidthCheckBox" @@ -457,7 +463,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "minimumTabWidthChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 9" + "value": "cell 0 10" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "hideContentSeparatorCheckBox" @@ -467,7 +473,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hideContentSeparatorChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 9" + "value": "cell 1 10" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "smallerInsetsCheckBox" @@ -477,7 +483,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "smallerInsetsChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 9" + "value": "cell 2 10 2 1" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "maximumTabWidthCheckBox" @@ -487,7 +493,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "maximumTabWidthChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 10" + "value": "cell 0 11" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "showTabSeparatorsCheckBox" @@ -497,7 +503,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "showTabSeparatorsChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 10" + "value": "cell 1 11" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "secondTabWiderCheckBox" @@ -507,7 +513,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "secondTabWiderChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 10" + "value": "cell 2 11 2 1" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "hideTabAreaWithOneTabCheckBox" @@ -517,7 +523,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hideTabAreaWithOneTabChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 11" + "value": "cell 1 12" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "customWheelScrollingCheckBox" @@ -527,7 +533,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "customWheelScrollingChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 11" + "value": "cell 2 12 2 1" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "contextMenuCheckBox" @@ -537,7 +543,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "contextMenuChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 12" + "value": "cell 2 13 2 1" } ) }, new FormLayoutConstraints( class com.jgoodies.forms.layout.CellConstraints ) { "gridY": 11 @@ -548,7 +554,7 @@ new FormModel { } ) }, new FormLayoutConstraints( null ) { "location": new java.awt.Point( 0, 0 ) - "size": new java.awt.Dimension( 810, 860 ) + "size": new java.awt.Dimension( 810, 960 ) } ) add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "hidemode 3,align center center" @@ -578,7 +584,7 @@ new FormModel { "value": "cell 2 0" } ) }, new FormLayoutConstraints( null ) { - "location": new java.awt.Point( 0, 890 ) + "location": new java.awt.Point( 0, 980 ) "size": new java.awt.Dimension( 291, 118 ) } ) add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { @@ -603,7 +609,7 @@ new FormModel { "value": "cell 1 0" } ) }, new FormLayoutConstraints( null ) { - "location": new java.awt.Point( 340, 890 ) + "location": new java.awt.Point( 340, 980 ) "size": new java.awt.Dimension( 291, 118 ) } ) } diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestEnumSelector.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestEnumSelector.java new file mode 100644 index 00000000..3298dd22 --- /dev/null +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatTestEnumSelector.java @@ -0,0 +1,112 @@ +/* + * Copyright 2023 FormDev Software GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.formdev.flatlaf.testing; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.beans.Beans; +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import javax.swing.JToggleButton; +import javax.swing.JToolBar; +import com.formdev.flatlaf.FlatClientProperties; + +/** + * @author Karl Tauber + */ +public class FlatTestEnumSelector + extends JPanel +{ + private final JToolBar toolBar; + + public FlatTestEnumSelector() { + super( new BorderLayout() ); + + toolBar = new JToolBar(); + toolBar.putClientProperty( FlatClientProperties.STYLE, "border: 1,1,1,1,$Component.borderColor,1,8; separatorWidth: 1" ); + add( toolBar ); + + // for JFormDesigner + if( Beans.isDesignTime() ) + toolBar.add( new JToggleButton( "(default)", true ) ); + } + + public void init( Class enumType, boolean supportDefault ) { + ButtonGroup group = new ButtonGroup(); + + // create "default" button + if( supportDefault ) + toolBar.add( createButton( "(default)", null, group ) ); + + // create value buttons + for( E value : enumType.getEnumConstants() ) { + if( getComponentCount() > 0 ) + toolBar.addSeparator(); + + toolBar.add( createButton( value.toString(), value, group ) ); + } + + // select first button in group + group.getElements().nextElement().setSelected( true ); + } + + private JToggleButton createButton( String text, E value, ButtonGroup group ) { + JToggleButton button = new JToggleButton( text ); + button.putClientProperty( "FlatTestEnumSelector.value", value ); + button.putClientProperty( FlatClientProperties.STYLE, "toolbar.spacingInsets: 0,0,0,0" ); + button.setEnabled( isEnabled() ); + button.addActionListener( e -> fireActionPerformed() ); + group.add( button ); + return button; + } + + @SuppressWarnings( "unchecked" ) + public E getSelectedValue() { + for( Component c : toolBar.getComponents() ) { + if( c instanceof JToggleButton && ((JToggleButton)c).isSelected() ) + return (E) ((JToggleButton)c).getClientProperty( "FlatTestEnumSelector.value" ); + } + return null; + } + + public void addActionListener( ActionListener l ) { + listenerList.add( ActionListener.class, l ); + } + + public void removeActionListener( ActionListener l ) { + listenerList.remove( ActionListener.class, l ); + } + + private void fireActionPerformed() { + ActionEvent e = new ActionEvent( this, ActionEvent.ACTION_PERFORMED, null ); + Object[] listeners = listenerList.getListenerList(); + for( int i = listeners.length - 2; i >= 0; i -= 2 ) { + if( listeners[i] == ActionListener.class ) + ((ActionListener)listeners[i+1]).actionPerformed( e ); + } + } + + @Override + public void setEnabled( boolean enabled ) { + super.setEnabled( enabled ); + + for( Component c : toolBar.getComponents() ) + c.setEnabled( enabled ); + } +} diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.java index 47d36450..1ac9bcd5 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.java @@ -412,13 +412,13 @@ public class FlatJideOssContainerTest showCloseButtonOnTabCheckBox = new JCheckBox(); showCloseButtonOnSelectedTabCheckBox = new JCheckBox(); JLabel tabPlacementLabel = new JLabel(); - tabPlacementField = new FlatTestEnumComboBox<>(); + tabPlacementField = new FlatTestEnumSelector<>(); secondTabClosableCheckBox = new JCheckBox(); showCloseButtonOnMouseOverCheckBox = new JCheckBox(); JLabel tabAreaAlignmentLabel = new JLabel(); - tabAlignmentField = new FlatTestEnumComboBox<>(); + tabAlignmentField = new FlatTestEnumSelector<>(); JLabel tabResizeModeLabel = new JLabel(); - tabResizeModeField = new FlatTestEnumComboBox<>(); + tabResizeModeField = new FlatTestEnumSelector<>(); leadingComponentCheckBox = new JCheckBox(); customBorderCheckBox = new JCheckBox(); tabAreaInsetsCheckBox = new JCheckBox(); @@ -478,7 +478,7 @@ public class FlatJideOssContainerTest "insets 0,hidemode 3", // columns "[]" + - "[fill]" + + "[]" + "[]", // rows "[center]" + @@ -506,7 +506,7 @@ public class FlatJideOssContainerTest //---- tabCountSpinner ---- tabCountSpinner.setModel(new SpinnerNumberModel(4, 0, null, 1)); tabCountSpinner.addChangeListener(e -> tabCountChanged()); - tabbedPaneControlPanel.add(tabCountSpinner, "cell 1 0"); + tabbedPaneControlPanel.add(tabCountSpinner, "cell 1 0,width 80"); //---- customTabsCheckBox ---- customTabsCheckBox.setText("Custom tabs"); @@ -674,11 +674,11 @@ public class FlatJideOssContainerTest private JCheckBox tabsClosableCheckBox; private JCheckBox showCloseButtonOnTabCheckBox; private JCheckBox showCloseButtonOnSelectedTabCheckBox; - private FlatTestEnumComboBox tabPlacementField; + private FlatTestEnumSelector tabPlacementField; private JCheckBox secondTabClosableCheckBox; private JCheckBox showCloseButtonOnMouseOverCheckBox; - private FlatTestEnumComboBox tabAlignmentField; - private FlatTestEnumComboBox tabResizeModeField; + private FlatTestEnumSelector tabAlignmentField; + private FlatTestEnumSelector tabResizeModeField; private JCheckBox leadingComponentCheckBox; private JCheckBox customBorderCheckBox; private JCheckBox tabAreaInsetsCheckBox; diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.jfd index 4454c5b7..669ca1c8 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/jideoss/FlatJideOssContainerTest.jfd @@ -1,4 +1,4 @@ -JFDML JFormDesigner: "7.0.3.1.342" Java: "16" encoding: "UTF-8" +JFDML JFormDesigner: "8.2.0.0.331" Java: "21" encoding: "UTF-8" new FormModel { contentType: "form/swing" @@ -64,7 +64,7 @@ new FormModel { } ) add( new FormContainer( "com.formdev.flatlaf.testing.FlatTestFrame$NoRightToLeftPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$layoutConstraints": "insets 0,hidemode 3" - "$columnConstraints": "[][fill][]" + "$columnConstraints": "[][][]" "$rowConstraints": "[center][][][][][]para[][]para[][][]" } ) { name: "tabbedPaneControlPanel" @@ -97,7 +97,7 @@ new FormModel { } addEvent( new FormEvent( "javax.swing.event.ChangeListener", "stateChanged", "tabCountChanged", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 0" + "value": "cell 1 0,width 80" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "customTabsCheckBox" @@ -205,7 +205,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 4" } ) - add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) { name: "tabPlacementField" auxiliary() { "JavaCodeGenerator.variableLocal": false @@ -242,7 +242,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 0 5" } ) - add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) { name: "tabAlignmentField" auxiliary() { "JavaCodeGenerator.variableLocal": false @@ -258,7 +258,7 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 2 5" } ) - add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumComboBox" ) { + add( new FormComponent( "com.formdev.flatlaf.testing.FlatTestEnumSelector" ) { name: "tabResizeModeField" auxiliary() { "JavaCodeGenerator.variableLocal": false