+ 1
JavaFX - How do you place a button in a circle without stacking and hiding the button
In the code given, a circle is created and a pane holds that circle. If I create a button called "OK" before I add my circle, the button gets hidden. Do i simply create and add the button AFTER I add my circle so that the button is not hidden? https://code.sololearn.com/cuW8GQlqHX7q/?ref=app
1 Resposta
+ 1
Yes the order of adding nodes makes a difference.
Circle c = new Circle();
Button b = new Button();
pane.getChildren().addAll(c, b);
-> button on the circle
pane.getChildren().addAll(b, c);
-> circle hides the button
Btw:
pane.getChildren().add(new Button("OK"));
This seems not a good idea if you want to add functionality to this button (mouse events).
Edit:
to place the button you can use setLayoutX() and setLayoutY()