color editor improvement

This commit is contained in:
bancika
2017-01-25 13:13:36 +01:00
parent c2aa863c2a
commit d35566cdf5
@@ -96,8 +96,7 @@ public class ColorEditor extends JPanel {
if (colorField == null) { if (colorField == null) {
Color color = (Color) property.getValue(); Color color = (Color) property.getValue();
colorField = colorField =
new JTextField(property.isUnique() ? Integer.toHexString(color.getRGB()).substring(2).toUpperCase() new JTextField(property.isUnique() ? Integer.toHexString(color.getRGB()).substring(2).toUpperCase() : "");
: ("(multi value) " + title));
colorField.setColumns(6); colorField.setColumns(6);
colorField.getDocument().addDocumentListener(new DocumentListener() { colorField.getDocument().addDocumentListener(new DocumentListener() {
@@ -123,8 +122,12 @@ public class ColorEditor extends JPanel {
private void updateColor() { private void updateColor() {
if (getColorField().getText().length() == 6) { if (getColorField().getText().length() == 6) {
Color newColor = Color.decode("#" + getColorField().getText()); Color newColor = Color.decode("#" + getColorField().getText());
if (newColor != null) if (newColor != null && getColorLabel().getBackground() != newColor) {
getColorLabel().setBackground(newColor); getColorLabel().setBackground(newColor);
getColorLabel().setText(title);
property.setChanged(true);
property.setValue(newColor);
}
} }
} }
} }