Reputation: 105
everyone. I am new in JavaFX, I have one problem maybe easier for you but spent me a lot of time, I still can not figure out. My problem is this:
I need to implement a swatch GUI with Java Scene Builder. I choose class Circle as swatch dial, and choose class Label to as time index(1, 2, 3, ... 12), and choose class Line as hour hand, minute hand and second hand.
When I want to do zoom in zoom out operations, I want that the Label(time Indexes) and the Line(swatch hands) can be the children of the Circle(swatch dial), but it seems can not. So, is there any method can zoom in or zoom out together this several nodes together?
Upvotes: 0
Views: 211
Reputation: 209428
Put all the nodes in a Group
and apply the zoom to the Group
.
Something like
Pane mainContainer = ... ;
Group watch = new Group();
Circle dial = new Circle(...);
Line hourHand = ... ;
Line minuteHand = ... ;
watch.getChildren().addAll(dial, hourHand, minuteHand);
Label[] timeLabels = new Label[12];
for (int i=1; i<=12; i++) {
timeLabels[i-1]= new Label(String.valueOf(i));
watch.getChildren().add(timeLabels[i-1]);
}
mainContainer.getChildren().add(watch);
Obviously you need to position the various pieces.
Then to zoom just do
watch.setScaleX(...);
watch.setScaleY(...);
Upvotes: 1