diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatBorder.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatBorder.java index e2a38d48..895a6cb9 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatBorder.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatBorder.java @@ -64,12 +64,8 @@ public class FlatBorder } protected Paint getBorderColor( Component c ) { - boolean editable = !(c instanceof JTextComponent) || ((JTextComponent)c).isEditable(); - return UIManager.getColor( c.isEnabled() && editable - ? (isFocused( c ) - ? "Component.focusedBorderColor" - : "Component.borderColor") - : "Component.disabledBorderColor" ); + boolean enabled = c.isEnabled() && (!(c instanceof JTextComponent) || ((JTextComponent)c).isEditable()); + return FlatUIUtils.getBorderColor( enabled, isFocused( c ) ); } protected boolean isFocused( Component c ) { 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 new file mode 100644 index 00000000..fc2d869f --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatComboBoxUI.java @@ -0,0 +1,124 @@ +/* + * 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 static com.formdev.flatlaf.util.UIScale.scale; +import java.awt.Color; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.geom.Path2D; +import java.awt.geom.Rectangle2D; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.UIManager; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicArrowButton; +import javax.swing.plaf.basic.BasicComboBoxUI; + +/** + * Provides the Flat LaF UI delegate for {@link javax.swing.JComboBox}. + * + * @author Karl Tauber + */ +public class FlatComboBoxUI + extends BasicComboBoxUI +{ + public static ComponentUI createUI( JComponent c ) { + return new FlatComboBoxUI(); + } + + @Override + protected JButton createArrowButton() { + return new FlatArrowButton(); + } + + @Override + public void update( Graphics g, JComponent c ) { + if( c.isOpaque() ) { + FlatUIUtils.paintParentBackground( g, c ); + + if( c.isEnabled() || comboBox.isEditable() ) { + Graphics2D g2 = (Graphics2D) g; + FlatUIUtils.setRenderingHints( g2 ); + + int width = c.getWidth(); + int height = c.getHeight(); + float focusWidth = FlatUIUtils.getFocusWidth(); + float arc = FlatUIUtils.getComponentArc(); + int arrowX = arrowButton.getX(); + + if( c.isEnabled() ) { + // paint background + g2.setColor( c.getBackground() ); + FlatUIUtils.fillRoundRectangle( g2, 0, 0, width, height, focusWidth, arc ); + + // paint arrow button background + g2.setColor( UIManager.getColor( comboBox.isEditable() + ? "ComboBox.buttonEditableBackground" + : "ComboBox.buttonBackground" ) ); + Shape oldClip = g2.getClip(); + g2.clipRect( arrowX, 0, width - arrowX, height ); + FlatUIUtils.fillRoundRectangle( g2, 0, 0, width, height, focusWidth, arc ); + g2.setClip( oldClip ); + } + + if( comboBox.isEditable() ) { + // paint vertical line between value and arrow button + g2.setColor( FlatUIUtils.getBorderColor( comboBox.isEnabled(), false ) ); + g2.fill( new Rectangle2D.Float( arrowX, focusWidth, scale( 1f ), height - (focusWidth * 2) ) ); + } + } + } + + paint( g, c ); + } + + //---- class FlatArrowButton ---------------------------------------------- + + private static class FlatArrowButton + extends BasicArrowButton + { + FlatArrowButton() { + super( SOUTH, Color.WHITE, Color.WHITE, Color.WHITE, Color.WHITE ); + + setOpaque( false ); + setBorder( null ); + } + + @Override + public void paint( Graphics g ) { + FlatUIUtils.setRenderingHints( (Graphics2D) g ); + + int w = scale( 9 ); + int h = scale( 5 ); + int x = Math.round( (getWidth() - w) / 2f ); + int y = Math.round( (getHeight() - h) / 2f ); + + Path2D arrow = new Path2D.Float(); + arrow.moveTo( x, y ); + arrow.lineTo( x + w, y ); + arrow.lineTo( x + (w / 2f), y + h ); + arrow.closePath(); + + g.setColor( UIManager.getColor( isEnabled() + ? "ComboBox.buttonArrowColor" + : "ComboBox.buttonDisabledArrowColor" ) ); + ((Graphics2D)g).fill( arrow ); + } + } +} diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRoundBorder.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRoundBorder.java new file mode 100644 index 00000000..e4d37d2a --- /dev/null +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatRoundBorder.java @@ -0,0 +1,31 @@ +/* + * 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; + +/** + * Border for various components (e.g. {@link javax.swing.JComboBox}). + * + * @author Karl Tauber + */ +public class FlatRoundBorder + extends FlatBorder +{ + @Override + protected float getArc() { + return FlatUIUtils.getComponentArc(); + } +} diff --git a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java index feba0b7f..30a6fc62 100644 --- a/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java +++ b/flatlaf-core/src/main/java/com/formdev/flatlaf/ui/FlatUIUtils.java @@ -17,6 +17,7 @@ package com.formdev.flatlaf.ui; import static com.formdev.flatlaf.util.UIScale.scale; +import java.awt.Color; import java.awt.Container; import java.awt.Graphics; import java.awt.Graphics2D; @@ -57,6 +58,12 @@ public class FlatUIUtils return scale( (float) getUIInt( "Button.arc", 6 ) ); } + public static Color getBorderColor( boolean enabled, boolean focused ) { + return UIManager.getColor( enabled + ? (focused ? "Component.focusedBorderColor" : "Component.borderColor") + : "Component.disabledBorderColor" ); + } + /** * Sets rendering hints used for painting. */ @@ -132,7 +139,7 @@ public class FlatUIUtils float x2 = x1 + width; float y2 = y1 + height; - float outerArc = arc > 0 ? arc + focusWidth - UIScale.scale( 2f ) : focusWidth; + float outerArc = (arc > 0) ? arc + focusWidth - UIScale.scale( 2f ) : focusWidth; Path2D outerRect = createOutlinePath( x1, y1, x2, y2, outerArc ); float ow = focusWidth + lineWidth; 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 b428b63b..2c3cc326 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties @@ -82,6 +82,15 @@ CheckBox.icon.checkmarkColor=A7A7A7 CheckBox.icon.disabledCheckmarkColor=606060 +#---- ComboBox ---- + +ComboBox.background=@textComponentBackground +ComboBox.buttonBackground=@textComponentBackground +ComboBox.buttonEditableBackground=404445 +ComboBox.buttonArrowColor=9A9DA1 +ComboBox.buttonDisabledArrowColor=585858 + + #---- Component ---- Component.borderColor=646464 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 24d9793e..d2d4f08c 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLaf.properties @@ -18,6 +18,7 @@ ButtonUI=com.formdev.flatlaf.ui.FlatButtonUI CheckBoxUI=com.formdev.flatlaf.ui.FlatCheckBoxUI +ComboBoxUI=com.formdev.flatlaf.ui.FlatComboBoxUI EditorPaneUI=com.formdev.flatlaf.ui.FlatEditorPaneUI FormattedTextFieldUI=com.formdev.flatlaf.ui.FlatFormattedTextFieldUI LabelUI=com.formdev.flatlaf.ui.FlatLabelUI @@ -48,6 +49,12 @@ CheckBox.border=com.formdev.flatlaf.ui.FlatMarginBorder CheckBox.icon=com.formdev.flatlaf.ui.FlatCheckBoxIcon +#---- ComboBox ---- + +ComboBox.border=com.formdev.flatlaf.ui.FlatRoundBorder +ComboBox.padding=1,6,1,6 + + #---- Component ---- Component.focusWidth=2 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 085c7df7..690a87fc 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties @@ -82,6 +82,15 @@ CheckBox.icon.checkmarkColor=FFFFFF CheckBox.icon.disabledCheckmarkColor=ABABAB +#---- ComboBox ---- + +ComboBox.background=@textComponentBackground +ComboBox.buttonBackground=@textComponentBackground +ComboBox.buttonEditableBackground=fafafa +ComboBox.buttonArrowColor=666666 +ComboBox.buttonDisabledArrowColor=ABABAB + + #---- Component ---- Component.borderColor=c4c4c4 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 3bd8edb0..771d4c6b 100644 --- a/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatComponentsTest.java +++ b/flatlaf-core/src/test/java/com/formdev/flatlaf/FlatComponentsTest.java @@ -75,6 +75,11 @@ public class FlatComponentsTest JRadioButton radioButton2 = new JRadioButton(); JRadioButton radioButton3 = new JRadioButton(); JRadioButton radioButton4 = new JRadioButton(); + JLabel comboBoxLabel = new JLabel(); + JComboBox comboBox1 = new JComboBox<>(); + JComboBox comboBox2 = new JComboBox<>(); + JComboBox comboBox3 = new JComboBox<>(); + JComboBox comboBox4 = new JComboBox<>(); JLabel textFieldLabel = new JLabel(); JTextField textField1 = new JTextField(); JTextField textField2 = new JTextField(); @@ -160,6 +165,7 @@ public class FlatComponentsTest "[]" + "[]" + "[]" + + "[]" + "[]")); //---- labelLabel ---- @@ -260,81 +266,125 @@ public class FlatComponentsTest radioButton4.setEnabled(false); add(radioButton4, "cell 4 3"); + //---- comboBoxLabel ---- + comboBoxLabel.setText("JComboBox:"); + add(comboBoxLabel, "cell 0 4"); + + //---- comboBox1 ---- + comboBox1.setEditable(true); + comboBox1.setModel(new DefaultComboBoxModel<>(new String[] { + "editable", + "a", + "bb", + "ccc" + })); + add(comboBox1, "cell 1 4,growx"); + + //---- comboBox2 ---- + comboBox2.setEditable(true); + comboBox2.setEnabled(false); + comboBox2.setModel(new DefaultComboBoxModel<>(new String[] { + "disabled", + "a", + "bb", + "ccc" + })); + add(comboBox2, "cell 2 4,growx"); + + //---- comboBox3 ---- + comboBox3.setModel(new DefaultComboBoxModel<>(new String[] { + "not editable", + "a", + "bb", + "ccc" + })); + add(comboBox3, "cell 3 4,growx"); + + //---- comboBox4 ---- + comboBox4.setModel(new DefaultComboBoxModel<>(new String[] { + "not editable disabled", + "a", + "bb", + "ccc" + })); + comboBox4.setEnabled(false); + add(comboBox4, "cell 4 4,growx"); + //---- textFieldLabel ---- textFieldLabel.setText("JTextField:"); - add(textFieldLabel, "cell 0 4"); + add(textFieldLabel, "cell 0 5"); //---- textField1 ---- textField1.setText("editable"); - add(textField1, "cell 1 4,growx"); + add(textField1, "cell 1 5,growx"); //---- textField2 ---- textField2.setText("disabled"); textField2.setEnabled(false); - add(textField2, "cell 2 4,growx"); + add(textField2, "cell 2 5,growx"); //---- textField3 ---- textField3.setText("not editable"); textField3.setEditable(false); - add(textField3, "cell 3 4,growx"); + add(textField3, "cell 3 5,growx"); //---- textField4 ---- textField4.setText("not editable disabled"); textField4.setEnabled(false); textField4.setEditable(false); - add(textField4, "cell 4 4,growx"); + add(textField4, "cell 4 5,growx"); //---- formattedTextFieldLabel ---- formattedTextFieldLabel.setText("JFormattedTextField:"); - add(formattedTextFieldLabel, "cell 0 5"); + add(formattedTextFieldLabel, "cell 0 6"); //---- formattedTextField1 ---- formattedTextField1.setText("editable"); - add(formattedTextField1, "cell 1 5,growx"); + add(formattedTextField1, "cell 1 6,growx"); //---- formattedTextField2 ---- formattedTextField2.setText("disabled"); formattedTextField2.setEnabled(false); - add(formattedTextField2, "cell 2 5,growx"); + add(formattedTextField2, "cell 2 6,growx"); //---- formattedTextField3 ---- formattedTextField3.setText("not editable"); formattedTextField3.setEditable(false); - add(formattedTextField3, "cell 3 5,growx"); + add(formattedTextField3, "cell 3 6,growx"); //---- formattedTextField4 ---- formattedTextField4.setText("not editable disabled"); formattedTextField4.setEnabled(false); formattedTextField4.setEditable(false); - add(formattedTextField4, "cell 4 5,growx"); + add(formattedTextField4, "cell 4 6,growx"); //---- passwordFieldLabel ---- passwordFieldLabel.setText("JPasswordField:"); - add(passwordFieldLabel, "cell 0 6"); + add(passwordFieldLabel, "cell 0 7"); //---- passwordField1 ---- passwordField1.setText("editable"); - add(passwordField1, "cell 1 6,growx"); + add(passwordField1, "cell 1 7,growx"); //---- passwordField2 ---- passwordField2.setText("disabled"); passwordField2.setEnabled(false); - add(passwordField2, "cell 2 6,growx"); + add(passwordField2, "cell 2 7,growx"); //---- passwordField3 ---- passwordField3.setText("not editable"); passwordField3.setEditable(false); - add(passwordField3, "cell 3 6,growx"); + add(passwordField3, "cell 3 7,growx"); //---- passwordField4 ---- passwordField4.setText("not editable disabled"); passwordField4.setEnabled(false); passwordField4.setEditable(false); - add(passwordField4, "cell 4 6,growx"); + add(passwordField4, "cell 4 7,growx"); //---- textAreaLabel ---- textAreaLabel.setText("JTextArea:"); - add(textAreaLabel, "cell 0 7"); + add(textAreaLabel, "cell 0 8"); //======== scrollPane1 ======== { @@ -346,7 +396,7 @@ public class FlatComponentsTest textArea1.setRows(2); scrollPane1.setViewportView(textArea1); } - add(scrollPane1, "cell 1 7,growx"); + add(scrollPane1, "cell 1 8,growx"); //======== scrollPane2 ======== { @@ -359,7 +409,7 @@ public class FlatComponentsTest textArea2.setEnabled(false); scrollPane2.setViewportView(textArea2); } - add(scrollPane2, "cell 2 7,growx"); + add(scrollPane2, "cell 2 8,growx"); //======== scrollPane3 ======== { @@ -372,7 +422,7 @@ public class FlatComponentsTest textArea3.setEditable(false); scrollPane3.setViewportView(textArea3); } - add(scrollPane3, "cell 3 7,growx"); + add(scrollPane3, "cell 3 8,growx"); //======== scrollPane4 ======== { @@ -386,16 +436,16 @@ public class FlatComponentsTest textArea4.setEnabled(false); scrollPane4.setViewportView(textArea4); } - add(scrollPane4, "cell 4 7,growx"); + add(scrollPane4, "cell 4 8,growx"); //---- textArea5 ---- textArea5.setRows(2); textArea5.setText("no scroll pane"); - add(textArea5, "cell 5 7,growx"); + add(textArea5, "cell 5 8,growx"); //---- editorPaneLabel ---- editorPaneLabel.setText("JEditorPane"); - add(editorPaneLabel, "cell 0 8"); + add(editorPaneLabel, "cell 0 9"); //======== scrollPane5 ======== { @@ -406,7 +456,7 @@ public class FlatComponentsTest editorPane1.setText("editable"); scrollPane5.setViewportView(editorPane1); } - add(scrollPane5, "cell 1 8,growx"); + add(scrollPane5, "cell 1 9,growx"); //======== scrollPane6 ======== { @@ -418,7 +468,7 @@ public class FlatComponentsTest editorPane2.setEnabled(false); scrollPane6.setViewportView(editorPane2); } - add(scrollPane6, "cell 2 8,growx"); + add(scrollPane6, "cell 2 9,growx"); //======== scrollPane7 ======== { @@ -430,7 +480,7 @@ public class FlatComponentsTest editorPane3.setEditable(false); scrollPane7.setViewportView(editorPane3); } - add(scrollPane7, "cell 3 8,growx"); + add(scrollPane7, "cell 3 9,growx"); //======== scrollPane8 ======== { @@ -443,15 +493,15 @@ public class FlatComponentsTest editorPane4.setEnabled(false); scrollPane8.setViewportView(editorPane4); } - add(scrollPane8, "cell 4 8,growx"); + add(scrollPane8, "cell 4 9,growx"); //---- editorPane5 ---- editorPane5.setText("no scroll pane"); - add(editorPane5, "cell 5 8,growx"); + add(editorPane5, "cell 5 9,growx"); //---- textPaneLabel ---- textPaneLabel.setText("JTextPane:"); - add(textPaneLabel, "cell 0 9"); + add(textPaneLabel, "cell 0 10"); //======== scrollPane9 ======== { @@ -462,7 +512,7 @@ public class FlatComponentsTest textPane1.setText("editable"); scrollPane9.setViewportView(textPane1); } - add(scrollPane9, "cell 1 9,growx"); + add(scrollPane9, "cell 1 10,growx"); //======== scrollPane10 ======== { @@ -474,7 +524,7 @@ public class FlatComponentsTest textPane2.setEnabled(false); scrollPane10.setViewportView(textPane2); } - add(scrollPane10, "cell 2 9,growx"); + add(scrollPane10, "cell 2 10,growx"); //======== scrollPane11 ======== { @@ -486,7 +536,7 @@ public class FlatComponentsTest textPane3.setEditable(false); scrollPane11.setViewportView(textPane3); } - add(scrollPane11, "cell 3 9,growx"); + add(scrollPane11, "cell 3 10,growx"); //======== scrollPane12 ======== { @@ -499,15 +549,15 @@ public class FlatComponentsTest textPane4.setEnabled(false); scrollPane12.setViewportView(textPane4); } - add(scrollPane12, "cell 4 9,growx"); + add(scrollPane12, "cell 4 10,growx"); //---- textPane5 ---- textPane5.setText("no scroll pane"); - add(textPane5, "cell 5 9,growx"); + add(textPane5, "cell 5 10,growx"); //---- scrollPaneLabel ---- scrollPaneLabel.setText("JScrollPane:"); - add(scrollPaneLabel, "cell 0 10"); + add(scrollPaneLabel, "cell 0 11"); //======== scrollPane13 ======== { @@ -521,55 +571,55 @@ public class FlatComponentsTest } scrollPane13.setViewportView(panel1); } - add(scrollPane13, "cell 1 10,grow,width 70,height 70"); - add(scrollBar2, "cell 2 10,growy"); + add(scrollPane13, "cell 1 11,grow,width 70,height 70"); + add(scrollBar2, "cell 2 11,growy"); //---- scrollBar3 ---- scrollBar3.setEnabled(false); - add(scrollBar3, "cell 2 10,growy"); - add(scrollPane14, "cell 3 10,grow"); + add(scrollBar3, "cell 2 11,growy"); + add(scrollPane14, "cell 3 11,grow"); //---- progressBar3 ---- progressBar3.setOrientation(SwingConstants.VERTICAL); progressBar3.setValue(50); - add(progressBar3, "cell 4 10"); + add(progressBar3, "cell 4 11"); //---- progressBar4 ---- progressBar4.setOrientation(SwingConstants.VERTICAL); progressBar4.setValue(55); progressBar4.setStringPainted(true); - add(progressBar4, "cell 4 10"); + add(progressBar4, "cell 4 11"); //---- scrollBarLabel ---- scrollBarLabel.setText("JScrollBar:"); - add(scrollBarLabel, "cell 0 11"); + add(scrollBarLabel, "cell 0 12"); //---- scrollBar1 ---- scrollBar1.setOrientation(Adjustable.HORIZONTAL); - add(scrollBar1, "cell 1 11,growx"); + add(scrollBar1, "cell 1 12,growx"); //---- scrollBar4 ---- scrollBar4.setOrientation(Adjustable.HORIZONTAL); scrollBar4.setEnabled(false); - add(scrollBar4, "cell 1 12,growx"); + add(scrollBar4, "cell 1 13,growx"); //---- progressBarLabel ---- progressBarLabel.setText("JProgressBar:"); - add(progressBarLabel, "cell 0 13"); + add(progressBarLabel, "cell 0 14"); //---- progressBar1 ---- progressBar1.setValue(50); - add(progressBar1, "cell 1 13"); + add(progressBar1, "cell 1 14"); //---- progressBar2 ---- progressBar2.setStringPainted(true); progressBar2.setValue(55); - add(progressBar2, "cell 3 13"); + add(progressBar2, "cell 3 14"); //---- indeterminateCheckBox ---- indeterminateCheckBox.setText("indeterminate"); indeterminateCheckBox.addActionListener(e -> indeterminateCheckBoxActionPerformed()); - add(indeterminateCheckBox, "cell 4 13"); + add(indeterminateCheckBox, "cell 4 14"); // 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 453c57c1..24dd8db4 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" "$columnConstraints": "[][][][][][]" - "$rowConstraints": "[][][][][][][][][][][][][][]" + "$rowConstraints": "[][][][][][][][][][][][][][][]" } ) { name: "this" add( new FormComponent( "javax.swing.JLabel" ) { @@ -148,31 +148,89 @@ new FormModel { }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { "value": "cell 4 3" } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "comboBoxLabel" + "text": "JComboBox:" + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 0 4" + } ) + add( new FormComponent( "javax.swing.JComboBox" ) { + name: "comboBox1" + "editable": true + "model": new javax.swing.DefaultComboBoxModel { + selectedItem: "editable" + addElement( "editable" ) + addElement( "a" ) + addElement( "bb" ) + addElement( "ccc" ) + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 1 4,growx" + } ) + add( new FormComponent( "javax.swing.JComboBox" ) { + name: "comboBox2" + "editable": true + "enabled": false + "model": new javax.swing.DefaultComboBoxModel { + selectedItem: "disabled" + addElement( "disabled" ) + addElement( "a" ) + addElement( "bb" ) + addElement( "ccc" ) + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 2 4,growx" + } ) + add( new FormComponent( "javax.swing.JComboBox" ) { + name: "comboBox3" + "model": new javax.swing.DefaultComboBoxModel { + selectedItem: "not editable" + addElement( "not editable" ) + addElement( "a" ) + addElement( "bb" ) + addElement( "ccc" ) + } + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 3 4,growx" + } ) + add( new FormComponent( "javax.swing.JComboBox" ) { + name: "comboBox4" + "model": new javax.swing.DefaultComboBoxModel { + selectedItem: "not editable disabled" + addElement( "not editable disabled" ) + addElement( "a" ) + addElement( "bb" ) + addElement( "ccc" ) + } + "enabled": false + }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { + "value": "cell 4 4,growx" + } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "textFieldLabel" "text": "JTextField:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 4" + "value": "cell 0 5" } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "textField1" "text": "editable" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 4,growx" + "value": "cell 1 5,growx" } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "textField2" "text": "disabled" "enabled": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 4,growx" + "value": "cell 2 5,growx" } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "textField3" "text": "not editable" "editable": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 4,growx" + "value": "cell 3 5,growx" } ) add( new FormComponent( "javax.swing.JTextField" ) { name: "textField4" @@ -180,33 +238,33 @@ new FormModel { "enabled": false "editable": 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: "formattedTextFieldLabel" "text": "JFormattedTextField:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 5" + "value": "cell 0 6" } ) add( new FormComponent( "javax.swing.JFormattedTextField" ) { name: "formattedTextField1" "text": "editable" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 5,growx" + "value": "cell 1 6,growx" } ) add( new FormComponent( "javax.swing.JFormattedTextField" ) { name: "formattedTextField2" "text": "disabled" "enabled": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 5,growx" + "value": "cell 2 6,growx" } ) add( new FormComponent( "javax.swing.JFormattedTextField" ) { name: "formattedTextField3" "text": "not editable" "editable": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 5,growx" + "value": "cell 3 6,growx" } ) add( new FormComponent( "javax.swing.JFormattedTextField" ) { name: "formattedTextField4" @@ -214,33 +272,33 @@ new FormModel { "enabled": false "editable": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 5,growx" + "value": "cell 4 6,growx" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "passwordFieldLabel" "text": "JPasswordField:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 6" + "value": "cell 0 7" } ) add( new FormComponent( "javax.swing.JPasswordField" ) { name: "passwordField1" "text": "editable" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 6,growx" + "value": "cell 1 7,growx" } ) add( new FormComponent( "javax.swing.JPasswordField" ) { name: "passwordField2" "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.JPasswordField" ) { name: "passwordField3" "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.JPasswordField" ) { name: "passwordField4" @@ -248,13 +306,13 @@ 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: "textAreaLabel" "text": "JTextArea:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 7" + "value": "cell 0 8" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane1" @@ -266,7 +324,7 @@ new FormModel { "rows": 2 } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 7,growx" + "value": "cell 1 8,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane2" @@ -279,7 +337,7 @@ new FormModel { "enabled": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 7,growx" + "value": "cell 2 8,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane3" @@ -292,7 +350,7 @@ new FormModel { "editable": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 7,growx" + "value": "cell 3 8,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane4" @@ -306,20 +364,20 @@ new FormModel { "enabled": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 7,growx" + "value": "cell 4 8,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 7,growx" + "value": "cell 5 8,growx" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "editorPaneLabel" "text": "JEditorPane" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 8" + "value": "cell 0 9" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane5" @@ -330,7 +388,7 @@ new FormModel { "text": "editable" } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 8,growx" + "value": "cell 1 9,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane6" @@ -342,7 +400,7 @@ new FormModel { "enabled": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 8,growx" + "value": "cell 2 9,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane7" @@ -354,7 +412,7 @@ new FormModel { "editable": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 8,growx" + "value": "cell 3 9,growx" } ) add( new FormContainer( "javax.swing.JScrollPane", new FormLayoutManager( class javax.swing.JScrollPane ) ) { name: "scrollPane8" @@ -367,19 +425,19 @@ new FormModel { "enabled": false } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 8,growx" + "value": "cell 4 9,growx" } ) add( new FormComponent( "javax.swing.JEditorPane" ) { name: "editorPane5" "text": "no scroll pane" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 5 8,growx" + "value": "cell 5 9,growx" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "textPaneLabel" "text": "JTextPane:" }, 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: "scrollPane9" @@ -390,7 +448,7 @@ new FormModel { "text": "editable" } ) }, 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: "scrollPane10" @@ -402,7 +460,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: "scrollPane11" @@ -414,7 +472,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: "scrollPane12" @@ -427,19 +485,19 @@ 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.JTextPane" ) { name: "textPane5" "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: "scrollPaneLabel" "text": "JScrollPane:" }, 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: "scrollPane13" @@ -450,23 +508,23 @@ new FormModel { "preferredSize": new java.awt.Dimension( 200, 200 ) } ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 10,grow,width 70,height 70" + "value": "cell 1 11,grow,width 70,height 70" } ) add( new FormComponent( "javax.swing.JScrollBar" ) { name: "scrollBar2" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 10,growy" + "value": "cell 2 11,growy" } ) add( new FormComponent( "javax.swing.JScrollBar" ) { name: "scrollBar3" "enabled": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 2 10,growy" + "value": "cell 2 11,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 10,grow" + "value": "cell 3 11,grow" } ) add( new FormComponent( "javax.swing.JProgressBar" ) { name: "progressBar3" @@ -476,7 +534,7 @@ new FormModel { "JavaCodeGenerator.variableLocal": false } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 10" + "value": "cell 4 11" } ) add( new FormComponent( "javax.swing.JProgressBar" ) { name: "progressBar4" @@ -487,32 +545,32 @@ new FormModel { "JavaCodeGenerator.variableLocal": false } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 10" + "value": "cell 4 11" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "scrollBarLabel" "text": "JScrollBar:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 11" + "value": "cell 0 12" } ) add( new FormComponent( "javax.swing.JScrollBar" ) { name: "scrollBar1" "orientation": 0 }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 11,growx" + "value": "cell 1 12,growx" } ) add( new FormComponent( "javax.swing.JScrollBar" ) { name: "scrollBar4" "orientation": 0 "enabled": false }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 12,growx" + "value": "cell 1 13,growx" } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "progressBarLabel" "text": "JProgressBar:" }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 0 13" + "value": "cell 0 14" } ) add( new FormComponent( "javax.swing.JProgressBar" ) { name: "progressBar1" @@ -521,7 +579,7 @@ new FormModel { "JavaCodeGenerator.variableLocal": false } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 1 13" + "value": "cell 1 14" } ) add( new FormComponent( "javax.swing.JProgressBar" ) { name: "progressBar2" @@ -531,7 +589,7 @@ new FormModel { "JavaCodeGenerator.variableLocal": false } }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 3 13" + "value": "cell 3 14" } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "indeterminateCheckBox" @@ -541,7 +599,7 @@ new FormModel { } addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "indeterminateCheckBoxActionPerformed", false ) ) }, new FormLayoutConstraints( class net.miginfocom.layout.CC ) { - "value": "cell 4 13" + "value": "cell 4 14" } ) }, 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 b3017877..880b797b 100644 --- a/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties +++ b/flatlaf-core/src/test/resources/com/formdev/flatlaf/FlatTestLaf.properties @@ -61,6 +61,15 @@ CheckBox.icon.checkmarkColor=FFFFFF CheckBox.icon.disabledCheckmarkColor=ABABAB +#---- ComboBox ---- + +ComboBox.background=ffffff +ComboBox.buttonBackground=f0f0f0 +ComboBox.buttonEditableBackground=cccccc +ComboBox.buttonArrowColor=666666 +ComboBox.buttonDisabledArrowColor=ABABAB + + #---- Component ---- Component.borderColor=ff0000