SceneBuilder src, or how to drag/size controls

Werner Lehmann lehmann at
Mon Feb 11 01:27:57 PST 2013


I have been experimenting with a few approaches on this, looks like I 
need a custom layout container which allows users to select, move, and 
resize child controls at runtime.

So far, the best approach seems to be to extend Region, filter on mouse 
events, and keep track of a "selected" child control. This control would 
get a special styleclass to show the selection border, e.g.

.selectedborder {
   -fx-border-width: 6;
   -fx-border-color: lightgray;
   -fx-border-insets: -6;

Two problems with this:

1. Removing the selectedborder styleclass does not remove the border. I 
actually have to switch to another styleclass to achieve this. Is this 
how it is supposed to be? I am afraid of removing any borders unrelated 
to the "selection":

.unselectedborder {
   -fx-border-width: 0;
   -fx-border-color: lightgray;
   -fx-border-insets: -0;

2. The approach won't work with anything not in the Region hierarchy 
which introduces the border styling. So for any Shape I am not getting a 
selection border. I guess this would change with FX8 then?

Alternatively, the selection border could be implemented by wrapping 
each child into a "layout private" AnchorPane - but that would expose a 
modified parent/child hierarchy to the outside which I'd like to avoid 
because node selection is an implementation detail.


On 04.02.2013 21:04, Jonathan Giles wrote:
> I can't speak to the first part of your email, but regarding resizing
> standard controls: as of JavaFX 8.0 Control extends from Region, so
> whilst I haven't tested Andrew's code, this should theoretically work.
> It would be worth testing, anyway :-)
> -- Jonathan

More information about the openjfx-dev mailing list