diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java index 863e5c0e..2976949f 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java @@ -585,7 +585,7 @@ public class FlatComboBoxUI FlatUIUtils.paintComponentBackground( g2, 0, 0, width, height, focusWidth, arc ); // paint arrow button background - if( enabled && !isCellRenderer ) { + if( enabled && !isCellRenderer && arrowButton.isVisible() ) { Color buttonColor = paintButton ? buttonEditableBackground : (buttonFocusedBackground != null || focusedBackground != null) && isPermanentFocusOwner( comboBox ) @@ -612,7 +612,7 @@ public class FlatComboBoxUI } // paint vertical line between value and arrow button - if( paintButton ) { + if( paintButton && arrowButton.isVisible() ) { Color separatorColor = enabled ? buttonSeparatorColor : buttonDisabledSeparatorColor; if( separatorColor != null && buttonSeparatorWidth > 0 ) { g2.setColor( separatorColor ); diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java index 30490fab..21530334 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.java @@ -59,6 +59,11 @@ public class FlatComponentsTest }; for( JSlider slider : allSliders ) slider.addChangeListener( sliderChanged ); + + UIManager.addPropertyChangeListener( e -> { + if( "lookAndFeel".equals( e.getPropertyName() ) && hideArrowButtonCheckBox.isSelected() ) + SwingUtilities.invokeLater( () -> hideArrowButton() ); + } ); } private void changeProgress() { @@ -127,6 +132,18 @@ public class FlatComponentsTest } } + private void hideArrowButton() { + boolean hideArrowButton = hideArrowButtonCheckBox.isSelected(); + + for( Component c : getComponents() ) { + if( c instanceof JComboBox ) { + Component b = ((JComboBox)c).getComponent( 0 ); + if( b instanceof AbstractButton ) + b.setVisible( !hideArrowButton ); + } + } + } + private void roundRectChanged() { Boolean roundRect = roundRectCheckBox.isSelected() ? true : null; @@ -380,6 +397,7 @@ public class FlatComponentsTest magentaOutlineRadioButton = new JRadioButton(); magentaCyanOutlineRadioButton = new JRadioButton(); focusPaintedCheckBox = new JCheckBox(); + hideArrowButtonCheckBox = new JCheckBox(); JLabel scrollBarLabel = new JLabel(); JScrollBar scrollBar1 = new JScrollBar(); JScrollBar scrollBar4 = new JScrollBar(); @@ -1234,9 +1252,10 @@ public class FlatComponentsTest "[]" + "[]", // rows - "[]" + - "[]" + - "[]" + + "[]0" + + "[]0" + + "[]0" + + "[]0" + "[]")); //---- buttonTypeComboBox ---- @@ -1290,13 +1309,18 @@ public class FlatComponentsTest magentaCyanOutlineRadioButton.addActionListener(e -> outlineChanged()); panel4.add(magentaCyanOutlineRadioButton); } - panel5.add(panel4, "cell 0 2 1 2"); + panel5.add(panel4, "cell 0 2 1 3"); //---- focusPaintedCheckBox ---- focusPaintedCheckBox.setText("focusPainted"); focusPaintedCheckBox.setSelected(true); focusPaintedCheckBox.addActionListener(e -> focusPaintedChanged()); panel5.add(focusPaintedCheckBox, "cell 1 2"); + + //---- hideArrowButtonCheckBox ---- + hideArrowButtonCheckBox.setText("hide arrow button"); + hideArrowButtonCheckBox.addActionListener(e -> hideArrowButton()); + panel5.add(hideArrowButtonCheckBox, "cell 1 3"); } add(panel5, "cell 5 13 2 10,grow"); @@ -1703,6 +1727,7 @@ public class FlatComponentsTest private JRadioButton magentaOutlineRadioButton; private JRadioButton magentaCyanOutlineRadioButton; private JCheckBox focusPaintedCheckBox; + private JCheckBox hideArrowButtonCheckBox; private JSlider slider1; private JSlider slider6; private JCheckBox sliderPaintTrackCheckBox; diff --git a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd index 71fa09a2..c62cb27d 100644 --- a/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd +++ b/flatlaf-testing/src/main/java/com/formdev/flatlaf/testing/FlatComponentsTest.jfd @@ -1,4 +1,4 @@ -JFDML JFormDesigner: "7.0.5.0.404" Java: "17.0.2" encoding: "UTF-8" +JFDML JFormDesigner: "8.3" encoding: "UTF-8" new FormModel { contentType: "form/swing" @@ -993,7 +993,7 @@ new FormModel { } ) add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class net.miginfocom.swing.MigLayout ) { "$columnConstraints": "[][]" - "$rowConstraints": "[][][][]" + "$rowConstraints": "[]0[]0[]0[]0[]" "$layoutConstraints": "ltr,insets dialog,hidemode 3" } ) { name: "panel5" @@ -1092,7 +1092,7 @@ new FormModel { addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "outlineChanged", false ) ) } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 2 1 2" + "value": "cell 0 2 1 3" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "focusPaintedCheckBox" @@ -1105,6 +1105,16 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 1 2" } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "hideArrowButtonCheckBox" + "text": "hide arrow button" + auxiliary() { + "JavaCodeGenerator.variableLocal": false + } + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "hideArrowButton", false ) ) + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 3" + } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 5 13 2 10,grow" } )