aspose file tools*
The moose likes JavaFX and the fly likes Add or Remove node in FXML loaded file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JavaFX
Bookmark "Add or Remove node in FXML loaded file" Watch "Add or Remove node in FXML loaded file" New topic
Author

Add or Remove node in FXML loaded file

john miltone
Greenhorn

Joined: Feb 01, 2013
Posts: 10

Hello everybody,

I want to interacted within my scene on the run.
Example : When I click on a button, I add a new node in my scene.

But Can I add or remove node in FXML loaded. If I can, how respect the hierarchy sceneGraph ?

How with ActionEvent interact on the same scene from the ActionEvent start ?

My real issue that I can't understand so much the function or system of the FXMLoader from JavaFX for "play" with this.




Thank a lot for your help
Danno Ferrin
Greenhorn

Joined: May 04, 2013
Posts: 2
You can absolutely do something like that. In fact, one of my demo apps does exactly what you describe.

https://bitbucket.org/shemnon/touchyfxy/src/be95b76b5f48593932af6e190af1abf8e7a8e904/src/main/java/touchyfxy/Controller.java?at=master#cl-320

At this line, in response to an update touch event, I go through all the children of a named node, remove some and add others. The key is that the node I am adding and removing the nodes to is identified via an fx:id tag in the FXML:

https://bitbucket.org/shemnon/touchyfxy/src/be95b76b5f48/src/main/resources/touchyfxy/touchyfxy.fxml?at=master#cl-222

john miltone
Greenhorn

Joined: Feb 01, 2013
Posts: 10

Hi Danno et thanks for your good way reply.

How have you generated ControllerGenerated class ? It's very good idea.
I don't understand the bound mean of a node. What this more simply ?

For the layout() function, what is the "Executes a top-down layout pass" result exactly ?

Have you (or can you) the binary of this application sample for understand this ensemble of scene ?



Danno Ferrin
Greenhorn

Joined: May 04, 2013
Posts: 2
john miltone wrote:Hi Danno et thanks for your good way reply.

How have you generated ControllerGenerated class ? It's very good idea.


I used SceneBuilder: http://www.oracle.com/technetwork/java/javafx/tools/index.html

john miltone wrote:I don't understand the bound mean of a node. What this more simply ?


Here is a tutorial on properties and bindings: http://docs.oracle.com/javafx/2/binding/jfxpub-binding.htm and then I changed the class name.

john miltone wrote:For the layout() function, what is the "Executes a top-down layout pass" result exactly ?


Generally you don't need to worry about the layout method in JavaFX, unless you are writing a layout manager. I've done quite a bit of JavaFX and have yet to need to figure that one out.

john miltone wrote:Have you (or can you) the binary of this application sample for understand this ensemble of scene ?


Depends on your platform, but here are some binaries: https://bintray.com/version/show/files/shemnon/javafx/touchyfxy/0.0
john miltone
Greenhorn

Joined: Feb 01, 2013
Posts: 10

I already use SceneBuilder but I don't know that create controller with him.
For bound, I don't speak about binding but more specific boundsInLocal for a Node. I already read the API doc here (Node API Ddoc), unfortunatably I don't understand very well this concept. Just help me to understand this with your word it's good (I don't remember what way in your code let me here but I want to understand nonetheless).

Generally you don't need to worry about the layout method in JavaFX, unless you are writing a layout manager. I've done quite a bit of JavaFX and have yet to need to figure that one out.


I speak about your code Controller class and more specific siezScrollCircles method.
Example : scrollEnd.layout();

Thank for your binaries distribution. Just pity that for gesture concept (good idea however).
 
Consider Paul's rocket mass heater.
 
subject: Add or Remove node in FXML loaded file