Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Extending javafx.animation.KeyValue public-init override problem

 
Fabricio Sanchez
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I want to extend class javafx.animation.KeyValue so that I can attach extra information to a KeyValue animation (inside a Timeline KeyFrame).

The problem I have is that the only way I've found of instantiating a KeyValue for a KeyFrame is:


So how can I initialise my subclass to something meaningful using the syntax above?
Solution Attempt 1:



I've also tried to generate an inner KeyValue, which I think works, however, I can't tie it in to the superclass public-init variables.
Solution Attempt 2:


For the above to work, I want to override the following variables that exist in javafx.animation.KeyValue


Any ideas?

Thank you,

Fabricio

 
Jim Clarke
author
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a bug, (JFXC-3979). You cannot override a public-init variable. I don't know when it will be fixed, but the work around is to initialize the variables in the object Literal for the sub-class.

MyKeyValue {
interpolate: Interpolater.EASE_BOTH
}
 
Fabricio Sanchez
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jim,

That worked. My extension class is just a dummy class now as I have to create and initialise everything outside it and then just set the initialisation values as you suggested.
Double the work until they fix this bug, but as long as it works.

Here's a description of what I'm doing for anyone who might want to try it:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic