javafx.scene.CssStyleHelper calculateValue JavaFX issue

Hey all I am not able to get the following code to work. it keeps giving me this error when I click on the textfield:

Aug 15, 2024 10:41:01 PM javafx.scene.CssStyleHelper calculateValue
WARNING: Caught 'java.lang.ClassCastException: class java.lang.String cannot be cast to class javafx.scene.paint.Paint (java.lang.String is in module java.base of loader 'bootstrap'; javafx.scene.paint.Paint is in module [email protected] of loader 'app')' while converting value for '-fx-border-color' from rule '*.text-input:focused' in stylesheet file:/C:/Users/Me/eclipse-workspace2/testMatBtn/bin/application/extended.css
Aug 15, 2024 10:41:01 PM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-material-design-color-transparent' while resolving lookups for '-fx-highlight-fill' from rule '*.text-input:focused' in stylesheet file:/C:/Users/Me/eclipse-workspace2/testMatBtn/bin/application/extended.css
Aug 15, 2024 10:41:01 PM javafx.scene.CssStyleHelper calculateValue
WARNING: Could not resolve '-material-design-color' while resolving lookups for '-fx-highlight-text-fill' from rule '*.text-input:focused' in stylesheet file:/C:/Users/Me/eclipse-workspace2/testMatBtn/bin/application/extended.css

I’m not really sure where its saying its having the issue at in my java controller:

ExtendedControl.java

package application;

import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.css.CssMetaData;
import javafx.css.SimpleStyleableObjectProperty;
import javafx.css.Styleable;
import javafx.css.StyleableProperty;
import javafx.css.StyleablePropertyFactory;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.util.Duration;

import java.util.List;


public class ExtendedControl extends TextField {
    private static final StyleablePropertyFactory<ExtendedControl> FACTORY                       = new StyleablePropertyFactory<>(TextField.getClassCssMetaData());
    private static final Color                                     DEFAULT_MATERIAL_DESIGN_COLOR = Color.web("#009688");
    private static final Color                                     DEFAULT_PROMPT_TEXT_COLOR     = Color.web("#757575");
    private static final double                                    STD_FONT_SIZE                 = 13;
    private static final double                                    SMALL_FONT_SIZE               = 10;
    private static final double                                    TOP_OFFSET_Y                  = 4;
    private static final int                                       ANIMATION_DURATION            = 60;
    private static final CssMetaData<ExtendedControl, Color>       MATERIAL_DESIGN_COLOR         = FACTORY.createColorCssMetaData("-material-design-color", s -> s.materialDesignColor, DEFAULT_MATERIAL_DESIGN_COLOR, false);
    private static final CssMetaData<ExtendedControl, Color>       PROMPT_TEXT_COLOR             = FACTORY.createColorCssMetaData("-prompt-text-color", s -> s.promptTextColor, DEFAULT_PROMPT_TEXT_COLOR, false);
    private static       String                                    userAgentStyleSheet;
    private        final StyleableProperty<Color>                  materialDesignColor;
    private        final StyleableProperty<Color>                  promptTextColor;
    private              Text                                      promptText;
    private              HBox                                      promptTextBox;
    private              DoubleProperty                            fontSize;
    private              Timeline                                  timeline;


    // ******************** Constructors **************************************
    public ExtendedControl() {
        this("");
    }
    public ExtendedControl(final String promptTextBox) {
        super(promptTextBox);

        materialDesignColor = new SimpleStyleableObjectProperty<>(MATERIAL_DESIGN_COLOR, this, "materialDesignColor");
        promptTextColor     = new SimpleStyleableObjectProperty<>(PROMPT_TEXT_COLOR, this, "promptTextColor");

        fontSize            = new SimpleDoubleProperty(ExtendedControl.this, "fontSize", getFont().getSize());
        timeline            = new Timeline();

        initGraphics();
        registerListeners();
    }


    // ******************** Initialization ************************************
    private void initGraphics() {
        getStyleClass().addAll("material-field");

        final String fontFamily = getFont().getFamily();
        final int    length      = getText().length();

        promptText = new Text(getPromptText());
        promptText.getStyleClass().add("prompt-text");

        promptTextBox = new HBox(promptText);
        promptTextBox.getStyleClass().add("material-field");

        if (!isEditable() || isDisabled() || length > 0) {
            promptText.setFont(Font.font(fontFamily, SMALL_FONT_SIZE));
            promptTextBox.setTranslateY(-STD_FONT_SIZE - TOP_OFFSET_Y);
        } else {
            promptText.setFont(Font.font(fontFamily, STD_FONT_SIZE));
        }

        getChildren().addAll(promptTextBox);
    }

    private void registerListeners() {
        textProperty().addListener(o -> handleTextAndFocus(isFocused()));
        promptTextProperty().addListener(o -> promptText.setText(getPromptText()));
        focusedProperty().addListener(o -> handleTextAndFocus(isFocused()));
        promptTextColorProperty().addListener(o -> promptText.setFill(getPromptTextColor()));
        fontSize.addListener(o -> promptText.setFont(Font.font(fontSize.get())));
        timeline.setOnFinished(evt -> {
            final int length = null == getText() ? 0 : getText().length();
            if (length > 0 && promptTextBox.getTranslateY() >= 0) {
                promptTextBox.setTranslateY(-STD_FONT_SIZE - TOP_OFFSET_Y);
                fontSize.set(SMALL_FONT_SIZE);
            }
        });
    }


    // ******************** CSS Stylable Properties ***************************
    public Color getMaterialDesignColor() { return materialDesignColor.getValue(); }
    public void setMaterialDesignColor(final Color color) { materialDesignColor.setValue(color); }
    public ObjectProperty<Color> materialDesignColorProperty() { return (ObjectProperty<Color>) materialDesignColor; }

    public Color getPromptTextColor() { return promptTextColor.getValue(); }
    public void setPromptTextColor(final Color color) { promptTextColor.setValue(color); }
    public ObjectProperty<Color> promptTextColorProperty() { return (ObjectProperty<Color>) promptTextColor; }


    // ******************** Misc **********************************************
    private void handleTextAndFocus(final boolean isFocused) {
        final int length = null == getText() ? 0 : getText().length();

        KeyFrame kf0;
        KeyFrame kf1;

        KeyValue kvTextY0;
        KeyValue kvTextY1;
        KeyValue kvTextFontSize0;
        KeyValue kvTextFontSize1;
        KeyValue kvPromptTextFill0;
        KeyValue kvPromptTextFill1;

        if (isFocused | length > 0 || isDisabled() || !isEditable()) {
            if (Double.compare(promptTextBox.getTranslateY(), -STD_FONT_SIZE - TOP_OFFSET_Y) != 0) {
                kvTextY0          = new KeyValue(promptTextBox.translateYProperty(), 0);
                kvTextY1          = new KeyValue(promptTextBox.translateYProperty(), -STD_FONT_SIZE - TOP_OFFSET_Y);
                kvTextFontSize0   = new KeyValue(fontSize, STD_FONT_SIZE);
                kvTextFontSize1   = new KeyValue(fontSize, SMALL_FONT_SIZE);
                kvPromptTextFill0 = new KeyValue(promptTextColorProperty(), DEFAULT_PROMPT_TEXT_COLOR);
                kvPromptTextFill1 = new KeyValue(promptTextColorProperty(), isFocused ? getMaterialDesignColor() : DEFAULT_PROMPT_TEXT_COLOR);

                kf0 = new KeyFrame(Duration.ZERO, kvTextY0, kvTextFontSize0, kvPromptTextFill0);
                kf1 = new KeyFrame(Duration.millis(ANIMATION_DURATION), kvTextY1, kvTextFontSize1, kvPromptTextFill1);

                timeline.getKeyFrames().setAll(kf0, kf1);
                timeline.play();
            }
            promptText.setFill(isFocused ? getMaterialDesignColor() : DEFAULT_PROMPT_TEXT_COLOR);
        } else {
            if (Double.compare(promptTextBox.getTranslateY(), 0) != 0) {
                kvTextY0          = new KeyValue(promptTextBox.translateYProperty(), promptTextBox.getTranslateY());
                kvTextY1          = new KeyValue(promptTextBox.translateYProperty(), 0);
                kvTextFontSize0   = new KeyValue(fontSize, SMALL_FONT_SIZE);
                kvTextFontSize1   = new KeyValue(fontSize, STD_FONT_SIZE);
                kvPromptTextFill0 = new KeyValue(promptTextColorProperty(), getMaterialDesignColor());
                kvPromptTextFill1 = new KeyValue(promptTextColorProperty(), DEFAULT_PROMPT_TEXT_COLOR);

                kf0 = new KeyFrame(Duration.ZERO, kvTextY0, kvTextFontSize0, kvPromptTextFill0);
                kf1 = new KeyFrame(Duration.millis(ANIMATION_DURATION), kvTextY1, kvTextFontSize1, kvPromptTextFill1);

                timeline.getKeyFrames().setAll(kf0, kf1);
                timeline.play();
            }
        }
    }


    // ******************** Style related *************************************
    @Override public String getUserAgentStylesheet() {
        if (null == userAgentStyleSheet) { userAgentStyleSheet = getClass().getResource("application/extended.css").toExternalForm(); }
        return userAgentStyleSheet;
    }

    public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData() { return FACTORY.getCssMetaData(); }
    @Override public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData() { return FACTORY.getCssMetaData(); }
}

Main.java

package application;

import java.io.File;
import java.net.URL;    
import javafx.application.Application;    
import javafx.fxml.FXMLLoader;    
import javafx.scene.Parent;
import javafx.scene.Scene;    
import javafx.stage.Stage;   

public class Main extends Application{
    @Override
    public void start(Stage primaryStage) throws Exception {
        URL url = new File("resources/application/main.fxml").toURI().toURL();          
        Parent root = FXMLLoader.load(url);
        root.getStylesheets().add("application/extended.css");    
        primaryStage.setScene(new Scene(root));
        primaryStage.show();    
    }

    public static void main(String[] args) {
        launch(args);
    }
}

Controller.java

package application;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.scene.shape.Rectangle;    
import java.net.URL;
import java.util.ResourceBundle;

public class Controller implements Initializable {
    @FXML
    private TextField blah;

    @FXML
    private TextField otherBlah;

    @FXML
    private Rectangle something;

    private ExtendedControl control;
    
    @Override
    public void initialize(URL location, ResourceBundle resources) { 
        blah = new ExtendedControl();
        blah.setPromptText("Name");            
    }
}

main.fxml

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.shape.*?>
<?import javafx.scene.control.*?>
<?import com.jfoenix.controls.*?>
<?import java.lang.*?>
<?import javafx.scene.layout.*?>

<AnchorPane fx:id="root" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Controller">
   <children>
      <Rectangle fx:id="something" arcHeight="5.0" arcWidth="5.0" fill="#1f93ff01" height="49.0" layoutX="261.0" layoutY="200.0" stroke="BLACK" strokeType="OUTSIDE" width="200.0" />
      <TextField fx:id="otherBlah" layoutX="279.0" layoutY="211.0" promptText="User Name" styleClass="materialfield" stylesheets="@mycss.css" />
      <TextField fx:id="blah" layoutX="37.0" layoutY="287.0" promptText="prompt"  />
   </children>
</AnchorPane>

extended.css

.material-field {
    -material-design-color            : #3f51b5;
    -material-design-color-transparent: #3f51b51f;
    -prompt-text-color                : #757575;
}
.material-field:readonly {
    -fx-prompt-text-fill: transparent;
}
.material-field:disabled {
    -fx-prompt-text-fill: transparent;
}

.text-input {
    -fx-font-family        : "Arial";
    -fx-font-size          : 13px;
    -fx-text-fill          : -fx-text-inner-color;
    -fx-highlight-fill     : derive(-fx-control-inner-background,-20%);
    -fx-highlight-text-fill: -fx-text-inner-color;
    -fx-prompt-text-fill   : transparent;
    -fx-background-color   : transparent;
    -fx-background-insets  : 0;
    -fx-background-radius  : 0;
    -fx-border-color       : transparent transparent #616161 transparent;
    -fx-border-width       : 1;
    -fx-border-insets      : 0 0 1 0;
    -fx-border-style       : hidden hidden solid hidden;
    -fx-cursor             : text;
    -fx-padding            : 0.166667em 0em 0.333333em 0em;
}
.text-input:focused {
    -fx-highlight-fill     : -material-design-color-transparent;
    -fx-highlight-text-fill: -material-design-color;
    -fx-text-fill          : -fx-text-inner-color;
    -fx-background-color   : transparent;
    -fx-border-color       : transparent transparent -material-design-color transparent;
    -fx-border-width       : 2;
    -fx-border-insets      : 0 0 2 -1;
    -fx-prompt-text-fill   : transparent;
    -fx-padding            : 2 0 4 0;
}
.text-input:readonly {
    -fx-background-color: transparent;
    -fx-text-fill       : derive(-fx-text-base-color, 35%);
    -fx-border-style    : segments(2, 3)  line-cap butt;
    -fx-border-color    : transparent transparent #616161 transparent;
}
.text-input:focused:readonly {
    -fx-text-fill   : derive(-fx-text-base-color, 35%);
    -fx-border-style: segments(2, 3)  line-cap butt;
    -fx-border-color: transparent transparent -material-design-color transparent;
}
.text-input:disabled {
    -fx-opacity     : 0.46;
    -fx-border-style: segments(2, 3)  line-cap butt;
    -fx-border-color: transparent transparent black transparent;
}

I normally do not post my full code but decided to do so this time since I’m told a lot to add more code for the issue.

Anyone know why it’s giving me those errors?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật