如何使Button出现在TitledPane JavaFX的右侧

时间:2018-03-06 04:50:04

标签: java javafx netbeans

我已经设法使用setGraphic将一个Button放在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

1 个答案:

答案 0 :(得分:1)

alignment的{​​{1}}属性设置为TitledPane

CENTER_RIGHT