Reputation: 33
I have managed to place a Button inside a TitledPane using setGraphic but I want it to be located on the right side; here is the code:
@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
Upvotes: 0
Views: 454
Reputation: 82451
Set the alignment
property of TitledPane
to CENTER_RIGHT
:
tp1.setAlignment(Pos.CENTER_RIGHT);
Upvotes: 1