0
我有更改我的按钮的位置的问题我想设置一个特定的位置放在哪里,但是当我使用.setLayoutX
和.setLayoutY
我甚至尝试过使用.relocate
,它仍然无法正常工作我做错了什么?这里是我的示例代码。JavaFx手动更改按钮的位置或位置?
CODE
Button b1 = new Button();
b1.setText("Press");
b1.setLayoutX(100);
b1.setLayoutY(120); // this are just some randome numbers for this sample
StackPane pane = new StackPane();
pane.getChildren().add(b1);
Scene scene = new Scene(pane,500,500);
stage.setScenes(scene);
stage.show();
当我运行该程序的按钮仍处于屏幕的中心做错了什么?
对于[示例](http://stackoverflow.com/a/31443755/230513),可能对'StackPane'使用'Pane'或其他对齐方式。 – trashgod
@trashgod:为什么人们会将评论发布为答案?它发生的越来越多,它开始变得烦人,因为每个人的时间都被浪费了。 – Roland
[在特定位置定位JavaFX按钮]的可能的重复(http://stackoverflow.com/questions/30641187/position-javafx-button-in-a-specific-location) – ItachiUchiha