我已经设法使用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
答案 0 :(得分:1)
将alignment
的{{1}}属性设置为TitledPane
:
CENTER_RIGHT