如何创建横向javafx手风琴?

时间:2015-12-15 09:23:49

标签: java javafx accordion horizontal-accordion

我需要创建一个水平的Accordion,titlePane中的标签和内容盘中的组件应该是水平的。 在我的代码中,我试图在内容中旋转手风琴和我的节点,但问题是手风琴没有展开以显示TitlePane的所有内容。我也不知道如何在TitlePane中旋转标题标签。

有谁知道怎么做?

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;
    }
}

0 个答案:

没有答案