add "success" border color

fix #945
This commit is contained in:
Valery Semenchuk
2025-03-08 14:57:06 +04:00
parent 411a2f6d29
commit 86a4d0ab12
6 changed files with 73 additions and 30 deletions

1
.gitignore vendored
View File

@@ -5,6 +5,7 @@ build/
.project .project
.settings/ .settings/
.idea/ .idea/
.consulo/
out/ out/
*.iml *.iml
*.ipr *.ipr

View File

@@ -226,6 +226,13 @@ public interface FlatClientProperties
*/ */
String OUTLINE = "JComponent.outline"; String OUTLINE = "JComponent.outline";
/**
* Paint the component border in another color (usually greenish) to indicate an success.
*
* @see #OUTLINE
*/
String OUTLINE_SUCCESS = "success";
/** /**
* Paint the component border in another color (usually reddish) to indicate an error. * Paint the component border in another color (usually reddish) to indicate an error.
* *

View File

@@ -55,6 +55,8 @@ import com.formdev.flatlaf.util.DerivedColor;
* @uiDefault Component.disabledBorderColor Color * @uiDefault Component.disabledBorderColor Color
* @uiDefault Component.focusedBorderColor Color * @uiDefault Component.focusedBorderColor Color
* *
* @uiDefault Component.success.borderColor Color
* @uiDefault Component.success.focusedBorderColor Color
* @uiDefault Component.error.borderColor Color * @uiDefault Component.error.borderColor Color
* @uiDefault Component.error.focusedBorderColor Color * @uiDefault Component.error.focusedBorderColor Color
* @uiDefault Component.warning.borderColor Color * @uiDefault Component.warning.borderColor Color
@@ -77,6 +79,8 @@ public class FlatBorder
@Styleable protected Color disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" ); @Styleable protected Color disabledBorderColor = UIManager.getColor( "Component.disabledBorderColor" );
@Styleable protected Color focusedBorderColor = UIManager.getColor( "Component.focusedBorderColor" ); @Styleable protected Color focusedBorderColor = UIManager.getColor( "Component.focusedBorderColor" );
@Styleable(dot=true) protected Color successBorderColor = UIManager.getColor( "Component.success.borderColor" );
@Styleable(dot=true) protected Color successFocusedBorderColor = UIManager.getColor( "Component.success.focusedBorderColor" );
@Styleable(dot=true) protected Color errorBorderColor = UIManager.getColor( "Component.error.borderColor" ); @Styleable(dot=true) protected Color errorBorderColor = UIManager.getColor( "Component.error.borderColor" );
@Styleable(dot=true) protected Color errorFocusedBorderColor = UIManager.getColor( "Component.error.focusedBorderColor" ); @Styleable(dot=true) protected Color errorFocusedBorderColor = UIManager.getColor( "Component.error.focusedBorderColor" );
@Styleable(dot=true) protected Color warningBorderColor = UIManager.getColor( "Component.warning.borderColor" ); @Styleable(dot=true) protected Color warningBorderColor = UIManager.getColor( "Component.warning.borderColor" );
@@ -163,6 +167,9 @@ public class FlatBorder
if( outline instanceof String ) { if( outline instanceof String ) {
switch( (String) outline ) { switch( (String) outline ) {
case FlatClientProperties.OUTLINE_SUCCESS:
return isFocused( c ) ? successFocusedBorderColor : successBorderColor;
case FlatClientProperties.OUTLINE_ERROR: case FlatClientProperties.OUTLINE_ERROR:
return isFocused( c ) ? errorFocusedBorderColor : errorBorderColor; return isFocused( c ) ? errorFocusedBorderColor : errorBorderColor;

View File

@@ -183,6 +183,8 @@ Component.linkColor = @accentLinkColor
Component.accentColor = if(@accentColor, @accentColor, @accentBaseColor) Component.accentColor = if(@accentColor, @accentColor, @accentBaseColor)
Component.grayFilter = -20,-70,100 Component.grayFilter = -20,-70,100
Component.success.borderColor = desaturate($Component.success.focusedBorderColor,25%)
Component.success.focusedBorderColor = #648b3c
Component.error.borderColor = desaturate($Component.error.focusedBorderColor,25%) Component.error.borderColor = desaturate($Component.error.focusedBorderColor,25%)
Component.error.focusedBorderColor = #8b3c3c Component.error.focusedBorderColor = #8b3c3c
Component.warning.borderColor = darken(desaturate($Component.warning.focusedBorderColor,20%),10%) Component.warning.borderColor = darken(desaturate($Component.warning.focusedBorderColor,20%),10%)

View File

@@ -190,6 +190,8 @@ Component.linkColor = @accentLinkColor
Component.accentColor = if(@accentColor, @accentColor, @accentBaseColor) Component.accentColor = if(@accentColor, @accentColor, @accentBaseColor)
Component.grayFilter = 25,-25,100 Component.grayFilter = 25,-25,100
Component.success.borderColor = lighten(desaturate($Component.success.focusedBorderColor,20%),25%)
Component.success.focusedBorderColor = #14dc92
Component.error.borderColor = lighten(desaturate($Component.error.focusedBorderColor,20%),25%) Component.error.borderColor = lighten(desaturate($Component.error.focusedBorderColor,20%),25%)
Component.error.focusedBorderColor = #e53e4d Component.error.focusedBorderColor = #e53e4d
Component.warning.borderColor = lighten(saturate($Component.warning.focusedBorderColor,25%),20%) Component.warning.borderColor = lighten(saturate($Component.warning.focusedBorderColor,25%),20%)

View File

@@ -179,6 +179,10 @@ class BasicComponentsPanel
JScrollPane scrollPane12 = new JScrollPane(); JScrollPane scrollPane12 = new JScrollPane();
JTextPane textPane4 = new JTextPane(); JTextPane textPane4 = new JTextPane();
JTextPane textPane5 = new JTextPane(); JTextPane textPane5 = new JTextPane();
JLabel successHintsLabel = new JLabel();
JTextField successHintsTextField = new JTextField();
JComboBox<String> successHintsComboBox = new JComboBox<>();
JSpinner successHintsSpinner = new JSpinner();
JLabel errorHintsLabel = new JLabel(); JLabel errorHintsLabel = new JLabel();
JTextField errorHintsTextField = new JTextField(); JTextField errorHintsTextField = new JTextField();
JComboBox<String> errorHintsComboBox = new JComboBox<>(); JComboBox<String> errorHintsComboBox = new JComboBox<>();
@@ -698,13 +702,33 @@ class BasicComponentsPanel
textPane5.setText("No scroll pane"); textPane5.setText("No scroll pane");
add(textPane5, "cell 5 11,growx"); add(textPane5, "cell 5 11,growx");
//---- successHintsLabel ----
successHintsLabel.setText("Success hints:");
add(successHintsLabel, "cell 0 12");
//---- successHintsTextField ----
successHintsTextField.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_SUCCESS);
add(successHintsTextField, "cell 1 12,growx");
//---- successHintsComboBox ----
successHintsComboBox.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_SUCCESS);
successHintsComboBox.setModel(new DefaultComboBoxModel<>(new String[] {
"Editable"
}));
successHintsComboBox.setEditable(true);
add(successHintsComboBox, "cell 2 12,growx");
//---- successHintsSpinner ----
successHintsSpinner.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_SUCCESS);
add(successHintsSpinner, "cell 3 12,growx");
//---- errorHintsLabel ---- //---- errorHintsLabel ----
errorHintsLabel.setText("Error hints:"); errorHintsLabel.setText("Error hints:");
add(errorHintsLabel, "cell 0 12"); add(errorHintsLabel, "cell 0 13");
//---- errorHintsTextField ---- //---- errorHintsTextField ----
errorHintsTextField.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_ERROR); errorHintsTextField.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_ERROR);
add(errorHintsTextField, "cell 1 12,growx"); add(errorHintsTextField, "cell 1 13,growx");
//---- errorHintsComboBox ---- //---- errorHintsComboBox ----
errorHintsComboBox.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_ERROR); errorHintsComboBox.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_ERROR);
@@ -712,131 +736,131 @@ class BasicComponentsPanel
"Editable" "Editable"
})); }));
errorHintsComboBox.setEditable(true); errorHintsComboBox.setEditable(true);
add(errorHintsComboBox, "cell 2 12,growx"); add(errorHintsComboBox, "cell 2 13,growx");
//---- errorHintsSpinner ---- //---- errorHintsSpinner ----
errorHintsSpinner.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_ERROR); errorHintsSpinner.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_ERROR);
add(errorHintsSpinner, "cell 3 12,growx"); add(errorHintsSpinner, "cell 3 13,growx");
//---- warningHintsLabel ---- //---- warningHintsLabel ----
warningHintsLabel.setText("Warning hints:"); warningHintsLabel.setText("Warning hints:");
add(warningHintsLabel, "cell 0 13"); add(warningHintsLabel, "cell 0 14");
//---- warningHintsTextField ---- //---- warningHintsTextField ----
warningHintsTextField.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_WARNING); warningHintsTextField.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_WARNING);
add(warningHintsTextField, "cell 1 13,growx"); add(warningHintsTextField, "cell 1 14,growx");
//---- warningHintsComboBox ---- //---- warningHintsComboBox ----
warningHintsComboBox.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_WARNING); warningHintsComboBox.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_WARNING);
warningHintsComboBox.setModel(new DefaultComboBoxModel<>(new String[] { warningHintsComboBox.setModel(new DefaultComboBoxModel<>(new String[] {
"Not editable" "Not editable"
})); }));
add(warningHintsComboBox, "cell 2 13,growx"); add(warningHintsComboBox, "cell 2 14,growx");
//---- warningHintsSpinner ---- //---- warningHintsSpinner ----
warningHintsSpinner.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_WARNING); warningHintsSpinner.putClientProperty(FlatClientProperties.OUTLINE, FlatClientProperties.OUTLINE_WARNING);
add(warningHintsSpinner, "cell 3 13,growx"); add(warningHintsSpinner, "cell 3 14,growx");
//---- iconsLabel ---- //---- iconsLabel ----
iconsLabel.setText("Leading/trailing icons:"); iconsLabel.setText("Leading/trailing icons:");
add(iconsLabel, "cell 0 14"); add(iconsLabel, "cell 0 15");
add(leadingIconTextField, "cell 1 14,growx"); add(leadingIconTextField, "cell 1 15,growx");
//---- trailingIconTextField ---- //---- trailingIconTextField ----
trailingIconTextField.setText("text"); trailingIconTextField.setText("text");
add(trailingIconTextField, "cell 2 14,growx"); add(trailingIconTextField, "cell 2 15,growx");
//---- iconsTextField ---- //---- iconsTextField ----
iconsTextField.setText("text"); iconsTextField.setText("text");
add(iconsTextField, "cell 3 14,growx"); add(iconsTextField, "cell 3 15,growx");
//---- compsLabel ---- //---- compsLabel ----
compsLabel.setText("Leading/trailing comp.:"); compsLabel.setText("Leading/trailing comp.:");
add(compsLabel, "cell 0 15"); add(compsLabel, "cell 0 15");
add(compsTextField, "cell 1 15 2 1,growx"); add(compsTextField, "cell 1 16 2 1,growx");
//---- clearTextField ---- //---- clearTextField ----
clearTextField.setText("clear me"); clearTextField.setText("clear me");
add(clearTextField, "cell 3 15,growx"); add(clearTextField, "cell 3 16,growx");
//---- fontsLabel ---- //---- fontsLabel ----
fontsLabel.setText("Typography / Fonts:"); fontsLabel.setText("Typography / Fonts:");
add(fontsLabel, "cell 0 16"); add(fontsLabel, "cell 0 17");
//---- h00Label ---- //---- h00Label ----
h00Label.setText("H00"); h00Label.setText("H00");
h00Label.putClientProperty(FlatClientProperties.STYLE_CLASS, "h00"); h00Label.putClientProperty(FlatClientProperties.STYLE_CLASS, "h00");
add(h00Label, "cell 1 16 5 1"); add(h00Label, "cell 1 17 5 1");
//---- h0Label ---- //---- h0Label ----
h0Label.setText("H0"); h0Label.setText("H0");
h0Label.putClientProperty(FlatClientProperties.STYLE_CLASS, "h0"); h0Label.putClientProperty(FlatClientProperties.STYLE_CLASS, "h0");
add(h0Label, "cell 1 16 5 1"); add(h0Label, "cell 1 17 5 1");
//---- h1Label ---- //---- h1Label ----
h1Label.setText("H1"); h1Label.setText("H1");
h1Label.putClientProperty(FlatClientProperties.STYLE_CLASS, "h1"); h1Label.putClientProperty(FlatClientProperties.STYLE_CLASS, "h1");
add(h1Label, "cell 1 16 5 1"); add(h1Label, "cell 1 17 5 1");
//---- h2Label ---- //---- h2Label ----
h2Label.setText("H2"); h2Label.setText("H2");
h2Label.putClientProperty(FlatClientProperties.STYLE_CLASS, "h2"); h2Label.putClientProperty(FlatClientProperties.STYLE_CLASS, "h2");
add(h2Label, "cell 1 16 5 1"); add(h2Label, "cell 1 17 5 1");
//---- h3Label ---- //---- h3Label ----
h3Label.setText("H3"); h3Label.setText("H3");
h3Label.putClientProperty(FlatClientProperties.STYLE_CLASS, "h3"); h3Label.putClientProperty(FlatClientProperties.STYLE_CLASS, "h3");
add(h3Label, "cell 1 16 5 1"); add(h3Label, "cell 1 17 5 1");
//---- h4Label ---- //---- h4Label ----
h4Label.setText("H4"); h4Label.setText("H4");
h4Label.putClientProperty(FlatClientProperties.STYLE_CLASS, "h4"); h4Label.putClientProperty(FlatClientProperties.STYLE_CLASS, "h4");
add(h4Label, "cell 1 16 5 1"); add(h4Label, "cell 1 17 5 1");
//---- lightLabel ---- //---- lightLabel ----
lightLabel.setText("light"); lightLabel.setText("light");
lightLabel.putClientProperty(FlatClientProperties.STYLE, "font: 200% $light.font"); lightLabel.putClientProperty(FlatClientProperties.STYLE, "font: 200% $light.font");
add(lightLabel, "cell 1 16 5 1,gapx 30"); add(lightLabel, "cell 1 17 5 1,gapx 30");
//---- semiboldLabel ---- //---- semiboldLabel ----
semiboldLabel.setText("semibold"); semiboldLabel.setText("semibold");
semiboldLabel.putClientProperty(FlatClientProperties.STYLE, "font: 200% $semibold.font"); semiboldLabel.putClientProperty(FlatClientProperties.STYLE, "font: 200% $semibold.font");
add(semiboldLabel, "cell 1 16 5 1"); add(semiboldLabel, "cell 1 17 5 1");
//---- fontZoomLabel ---- //---- fontZoomLabel ----
fontZoomLabel.setText("(200%)"); fontZoomLabel.setText("(200%)");
fontZoomLabel.putClientProperty(FlatClientProperties.STYLE_CLASS, "small"); fontZoomLabel.putClientProperty(FlatClientProperties.STYLE_CLASS, "small");
fontZoomLabel.setEnabled(false); fontZoomLabel.setEnabled(false);
add(fontZoomLabel, "cell 1 16 5 1"); add(fontZoomLabel, "cell 1 17 5 1");
//---- largeLabel ---- //---- largeLabel ----
largeLabel.setText("large"); largeLabel.setText("large");
largeLabel.putClientProperty(FlatClientProperties.STYLE_CLASS, "large"); largeLabel.putClientProperty(FlatClientProperties.STYLE_CLASS, "large");
add(largeLabel, "cell 1 17 5 1"); add(largeLabel, "cell 1 18 5 1");
//---- defaultLabel ---- //---- defaultLabel ----
defaultLabel.setText("default"); defaultLabel.setText("default");
add(defaultLabel, "cell 1 17 5 1"); add(defaultLabel, "cell 1 18 5 1");
//---- mediumLabel ---- //---- mediumLabel ----
mediumLabel.setText("medium"); mediumLabel.setText("medium");
mediumLabel.putClientProperty(FlatClientProperties.STYLE_CLASS, "medium"); mediumLabel.putClientProperty(FlatClientProperties.STYLE_CLASS, "medium");
add(mediumLabel, "cell 1 17 5 1"); add(mediumLabel, "cell 1 18 5 1");
//---- smallLabel ---- //---- smallLabel ----
smallLabel.setText("small"); smallLabel.setText("small");
smallLabel.putClientProperty(FlatClientProperties.STYLE_CLASS, "small"); smallLabel.putClientProperty(FlatClientProperties.STYLE_CLASS, "small");
add(smallLabel, "cell 1 17 5 1"); add(smallLabel, "cell 1 18 5 1");
//---- miniLabel ---- //---- miniLabel ----
miniLabel.setText("mini"); miniLabel.setText("mini");
miniLabel.putClientProperty(FlatClientProperties.STYLE_CLASS, "mini"); miniLabel.putClientProperty(FlatClientProperties.STYLE_CLASS, "mini");
add(miniLabel, "cell 1 17 5 1"); add(miniLabel, "cell 1 18 5 1");
//---- monospacedLabel ---- //---- monospacedLabel ----
monospacedLabel.setText("monospaced"); monospacedLabel.setText("monospaced");
monospacedLabel.putClientProperty(FlatClientProperties.STYLE_CLASS, "monospaced"); monospacedLabel.putClientProperty(FlatClientProperties.STYLE_CLASS, "monospaced");
add(monospacedLabel, "cell 1 17 5 1,gapx 30"); add(monospacedLabel, "cell 1 18 5 1,gapx 30");
//======== popupMenu1 ======== //======== popupMenu1 ========
{ {