Search in sources :

Example 1 with WebColorField

use of com.fxexperience.javafx.scene.control.WebColorField in project fxexperience2 by EricCanull.

the class WebColorFieldSkin method updateText.

@Override
protected void updateText() {
    Color color = ((WebColorField) control).getValue();
    if (color == null)
        color = Color.BLACK;
    getTextField().setText(getWebColor(color));
}
Also used : Color(javafx.scene.paint.Color) WebColorField(com.fxexperience.javafx.scene.control.WebColorField)

Example 2 with WebColorField

use of com.fxexperience.javafx.scene.control.WebColorField in project fxexperience2 by EricCanull.

the class WebColorFieldSkin method updateValue.

@Override
protected void updateValue() {
    Color value = ((WebColorField) control).getValue();
    String text = getTextField().getText() == null ? "" : getTextField().getText().trim().toUpperCase();
    if (text.matches("#[A-F0-9]{6}")) {
        try {
            Color newValue = Color.web(text);
            if (!newValue.equals(value)) {
                ((WebColorField) control).setValue(newValue);
            }
        } catch (java.lang.IllegalArgumentException ex) {
            System.out.println("Failed to parse [" + text + "]");
        }
    }
}
Also used : Color(javafx.scene.paint.Color) WebColorField(com.fxexperience.javafx.scene.control.WebColorField)

Aggregations

WebColorField (com.fxexperience.javafx.scene.control.WebColorField)2 Color (javafx.scene.paint.Color)2