gpt4 book ai didi

java - 如何使按钮出现在 TitledPane JavaFX 的右侧

转载 作者:行者123 更新时间:2023-12-02 11:33:19 26 4
gpt4 key购买 nike

我已经设法使用 setGraphic 在 TitledPane 中放置一个按钮,但我希​​望它位于右侧;这是代码:

@Override
public void start(Stage primaryStage) {

Accordion acordion = new Accordion();

TitledPane tp1 = new TitledPane();

Button b1 = new Button();

b1.setText("X");

tp1.setGraphic(b1);

acordion.getPanes().addAll(tp1);

Scene scene = new Scene(acordion, 300, 250);

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

public static void main(String[] args) {
launch(args);
}

The Button should be located on the right but I do not know how to do it

enter image description here

最佳答案

TitledPanealignment 属性设置为 CENTER_RIGHT:

tp1.setAlignment(Pos.CENTER_RIGHT);

关于java - 如何使按钮出现在 TitledPane JavaFX 的右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49123583/

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