Reputation: 7228
I need to create a horizontal Accordion which the label in the titlePane and the component in the content pan should be horizontal. In my code i tried to rotate the accordion and my node in the content but problem is the accordion does not expand to show all content of TitlePane. Also i do not know how to rotate the title label in the TitlePane.
Does anyone know how to do it?
public class HorizontalAccordionSample extends Application {
final String[] types = new String[] { "Home", "Works", "Office",
"Home Work Office" };
final String[] subType = new String[] { "Infusion", "Non Infusion",
"Combination" };
final TitledPane[] tps = new TitledPane[types.length];
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
stage.setTitle("TitledPane");
Scene scene = new Scene(new Group(), 80, 180);
scene.setFill(Color.GHOSTWHITE);
final Accordion accordion = new Accordion();
accordion.setRotate(-90);
for (int i = 0; i < types.length; i++) {
tps[i] = new TitledPane(types[i], createNode());
}
accordion.getPanes().addAll(tps);
accordion.setExpandedPane(tps[1]);
Group root = (Group) scene.getRoot();
root.getChildren().add(accordion);
stage.setScene(scene);
stage.show();
}
private Node createNode() {
FlowPane flow = new FlowPane();
flow.setRotate(90);
flow.setVgap(8);
flow.setHgap(4);
// flow.setPrefWrapLength(800);
for (String sub : subType) {
RadioButton radioButton = new RadioButton(sub);
// radioButton.setRotate(- 90);
flow.getChildren().add(radioButton);
}
return flow;
}
}
Upvotes: 2
Views: 868