JavaFX and the Missing Interfaces
Knut Arne Vedaa
knut.arne.vedaa at broadpark.no
Mon Nov 5 11:49:05 PST 2012
While you want
NodeBase implements Node
but would be happy with
Node implements SceneNode
I'd propose a third alternative (which I prefer to the first):
Node implements NodeLike
This naming scheme is used a lot in Scala's standard library (but for
traits and not interfaces, the former which can have concrete members).
Speaking of - if I understand your blog post correctly, what you want is
this:
trait IControl extends Control {
def iCommonMethod = "something"
}
class ITextField extends TextField with IControl
def fooBar(iControl: IControl) {
iControl setTooltip new Tooltip("foo bar")
iControl.iCommonMethod
}
fooBar(iTextField)
val iTextField = new ITextField
iTextField.iCommonMethod
Which is perfectly valid Scala code. So if you can't convince the powers
that be to refactor the API, you have at least another option, hint hint. :)
Knut Arne Vedaa
On 05.11.2012 19:50, Randahl Fink Isaksen wrote:
> I have been struggling with a number of problems stemming from the way JavaFX is designed – specifically the lack of interfaces for many of the extension points in the class hierarchy.
>
> It takes some thorough explaining with code examples, so instead of just an unformatted e-mail I posted a more readable explanation of the problem on-line:
> Please read http://blog.randahl.dk/2012/11/javafx-and-missing-interfaces.html
>
> I hope we could have a constructive discussion on this matter on this list before I go ahead and file a Jira, so the Jira issue becomes the best possible basis for solving the design problem.
>
> Thanks
>
> Randahl
>
More information about the openjfx-dev
mailing list