JavaFX nodes - How to make them resizable by the end user?
Asked Answered
T

1

7

I am developing a JavaFX application where a class I have developed (extended from javafx.scene.Parent) is created on-the-fly based on what entry the user has clicked in a ListView control.

Just to be clear about this node, it is not created using a layout tool like SceneBuilder, it is created at runtime based on the user's actions.

The constructor for my custom node class creates a VBox and a Label and uses passed coordinates (X,Y) in the constructor method to set its own Layout coords. I then use a custom utility class to make the node draggable. This new node is then added to the main application Pane.

However, I have failed to find out how I can make these nodes resizable by the user. That is, allow the user to mouse over the corner of the node, hold and drag to resize. An operation that all users are used to, no matter what the OS.

Has anyone done anything like this in JavaFX? (My searches on the subject only seem to pull up subjects on the automatic resizing that a parent node does with its child nodes.)

Many thanks,

Ian.

Torrence answered 1/10, 2013 at 14:26 Comment(0)
B
1

As you can see on the documentation of VBox you can only define minimum, prefered and maximum range, there's not really a way to make it manually resizable.

The only proper solution to solve your problem is to develop your own class to do it, because what you want seems very specific, with your problem description, I don't think use some layouts or panels will do what you exactly want.

I found something that you can use : Dragging to resize a JavaFX Region

This allows you to resize a region, all you have to do after is to put you VBox in this region, but notice in this article that :

Only height resizing is currently implemented.

This code won't work in JavaFX8, you'll have to check the comment to see how it worls in JavaFX8

Hope this helps.

Boron answered 22/5, 2015 at 10:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.