gpt4 book ai didi

JavaFx如何将文本写入特定位置

转载 作者:行者123 更新时间:2023-12-01 16:15:49 26 4
gpt4 key购买 nike

这是我的代码:

public class Canvas extends Application {

@Override
public void start(Stage primaryStage) {
root = new BorderPane();
//...
player = new Player();
HBox topPanel = new HBox(currency);
topPanel.setLayoutX(20);
topPanel.setLayoutY(40);
topPanel.setSpacing(40);
root.setLeft(topPanel);

}
}

我希望我的货币号码显示在某个特定位置(不完全是顶部中心) - 基于我的应用程序中的其他图像。我怎样才能做到这一点?

最佳答案

您可以尝试使用Text并为其设置特定的x和y坐标。

    @Override
public void start(Stage stage) {
int x = 50, y = 100;
int currency = 10000;

Text currencyText = new Text(x, y, String.valueOf(currency));

Group root = new Group(currencyText);

Scene scene = new Scene(root, 600, 300);

stage.setScene(scene);
stage.show();
}

关于JavaFx如何将文本写入特定位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62392293/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com