0

Here I found a question with answers how to make label blink programmatically. However, I need to make my text blink in RichTextFX. So, I need a solution that can provide this functionality using only CSS.

I tried this:

.my-class {
     -fx-animation: blinker 1s linear infinite;
}

@keyframes blinker {
  50% {
    -fx-opacity: 0;
  }
}

But as it was found out, JavaFX doesn't support -fx-animation and @keyframes.

If it is possible, could anyone say how to do it?

Pavel_K
  • 10,748
  • 13
  • 73
  • 186
  • No, JavaFX CSS does not support animation. Blinking text can only be implemented programmatically. As an aside, in my opinion blinking text creates a horrible user experience, and should not be used in any circumstances. – James_D Mar 22 '22 at 14:43
  • @James_D Thank you for your comment. I totally agree with you that text blinking is a horrible user experience. But I work on project that must support this functionality... – Pavel_K Mar 22 '22 at 14:45
  • See [animating css](https://stackoverflow.com/questions/17676274/how-to-make-an-animation-with-css-in-javafx). You should be able to vary the color of a looked up color to animate it. See the css reference if you don’t know what a looked up color is. The Color class implements Interpolatable so you can use an Interpolator to calculate intermediate values. Complex css such as a style sheet can be represented in code by a data url and changed dynamically in a timeline if needed. – jewelsea Mar 22 '22 at 16:42

0 Answers0