How to place a rotated node inside a container?

I want to add Hyperlink to my JavaFX 2 application. This link can be vertical in the left or right part of my application, just as you see it with minimal and pinned modules in many applications - for example, IntelliJ IDEA.

Turns out node placement is difficult even in SceneBuilder, as the container keeps growing or changes the Hyperlink coordinates when I want to rotate it.

So my question is: how can I place one or more nodes that rotate 90 or 270 degrees inside a container (preferably VBox or AnchorPane ) whose size is fixed?

+4
source share
2 answers

Place the rotated node in the Group - this way the layoutBounds of the group will match the boundsInParent of the rotated Node . This is probably what you want, because it means that the visual borders of the node are now used for layout purposes. This works for layout managers who automatically move nodes (like VBox ).

+7
source

You probably want to do this in code, not SceneBuilder. You can add a node to the parent (VBox or the like) and apply rotary conversion to it. Remember that all user interface elements in JavaFX are just nodes in a script that can be transformed anyway.

See also javadoc Node, paragraph on conversions.

+1
source

All Articles