Skip to main content

JavaFX Widget Classes

2 replies [Last post]
cworley420
Offline
Joined: 2008-06-27

I think I am missing a fundamental concept with JavaFX.

I want to create a widget class that encapsulates other widgets to make a more complex widget. A good example is a postal address form. Normally with swing I would extend JPanel and add a number of labels and text fields creating a postal address form. Since the class JPanel I could add it to other panels.

I cannot figure out who to do this with JavaFX in a way that seems proper. The best I have done is extend Widget then override createComponent which returns a JComponent. Since I have to return a JComponent I can't figure out how to use the JavaFX UI for my widget. Instead of returning Panel { } I have to return new JPanel().

Most example I find just have one Frame and all the widgets are contained in that file; therefore, the author does not need to break widgets up into multiple classes. I have seen some use the CompositeNode to develop a pure java fx widget.

How should I write a pure java fx widget class that can be reused?

-chris worley

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
rlasjunies
Offline
Joined: 2008-06-08

Hi,

I think the answer is "customnode"

You will found interesting examples here. http://learnjavafx.typepad.com/

Hope will help

Regards,

michael_heinrichs
Offline
Joined: 2007-11-15

Yes, CustomNode is what you need to extend. Also take a look at Canvas and ComponentView, which provide bridges between the Component-world and the Node-world.