openjfx-dev Digest, Vol 8, Issue 25
daniel.fuchs at oracle.com
Thu Jul 12 12:01:54 PDT 2012
On 7/12/12 7:22 PM, openjfx-dev-request at openjdk.java.net wrote:
> Date: Thu, 12 Jul 2012 19:08:37 +0200
> From: Werner Lehmann<lehmann at media-interactive.de>
> Subject: Re: Scene Builder and<fx:root>
> To:openjfx-dev at openjdk.java.net
> Message-ID:<4FFF0495.3010202 at media-interactive.de>
> Content-Type: text/plain; charset="windows-1252"; format=flowed
> On 12.07.2012 18:28, Daniel Fuchs wrote:
>> > As Greg says - you will need to provide a value for the
>> > fx:type attribute in fx:root - and you should be able
>> > to load that in SceneBuilder.
>> > SceneBuilder does not allow you to set fx:root from within
>> > SceneBuilder itself (I mean, if you create an FXML from
>> > within SceneBuilder it will not have the fx:root element) - but
>> > if you load an FXML whose root element is fx:root then
>> > SceneBuilder should be able to load it, and will preserve it.
> that works indeed. I just had to use "BorderPane" as fx:root type
> attribute value instead of my derived class which SB cannot know about.
> What about my other question as to how custom controls can be used in
> Scene Builder? Can I add them to the library, and would it pick up any
> new properties on the right hand side of the SB window? Or, is it
> possible to just manually edit that part of the FXML but still use SB
> for the rest of it?
So several questions here:
1. No you cannot add your own controls to the Library with SceneBuilder 1.0.
2. However if your FXML already contains your own controls, SceneBuilder
should be able to
load it, unless they require specific builders/builder factory.
At first load SceneBuilder will recognize that your FXML contains
types that it
does not know about - and will pop up dialog allowing you to enter
In some cases, SceneBuilder might be able to load the file even if
you choose to
not provide a classpath - but in that case - the unknown types will
displayed - neither on the content view - nor in the hierarchy panel.
Their FXML elements will be preserved however.
If you choose to provide a classpath however, SceneBuilder should
be able to
render your custom controls, and you will be able to manipulate them.
The properties that are specific to your controls will appear in a
category in the inspector.
Since SceneBuilder doesn't know about your custom types - it might
not be able
to display their subnodes in the Hierarchy Panel. For instance - if
extends Pane, then SceneBuilder will assume that the children are
to be found in
the Pane.getChildren() property. However - if it extends Region
directly - then
the children will not be manipulable. In other words SceneBuilder
scenegraph through the lens of the javafx classes it knows about.
3. If you have provided a classpath - then copy/paste should work also
custom types. So if you have an instance of "FooControl" you should
to use copy/paste to create another one.
4. Be also aware that if your custom control behave badly - then
happen - for instance if one of your custom controls enters in an
loop during layout it can block the UI.
So in practice - if you wish to add your own controls and work with them in
SceneBuilder you could:
a. create a skeleton FXML using SceneBuilder
b. at the place where you would like to insert your own control, insert
a place holder instance of its closest JavaFX super class.
c. save and close the file.
d. In NetBeans or Eclipse (or emacs ;-)) change the name of the place
replace the name of the javafx class with your own custom class.
Don't forget to add the appropriate <?import ?> clause at the beginning
e. From File > Open Recent > - open your file again. You will get the
pop up asking for a classpath. Provide the classpath and you should
be able to load the file.
hope this helps,
More information about the openjfx-dev