阅读量:0
JavaFX布局-Accordion
- 一个可扩展的面板,包括标题、内容
- 与
TitledPane
配合一起使用
public static Accordion demo1() { // 创建Accordion Accordion accordion = new Accordion(); // 内边距 accordion.setPadding(new Insets(10, 10, 10, 10)); for (int i = 1; i <= 10; i++) { TitledPane titledPane = new TitledPane(); titledPane.setText("TitledPane " + i); titledPane.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT); ScrollPane scrollPane = new ScrollPane(); FlowPane flowPane = new FlowPane(); flowPane.setOrientation(Orientation.VERTICAL); flowPane.prefWidthProperty().bind(scrollPane.widthProperty().subtract(20)); scrollPane.setContent(flowPane); for (int j = 1; j <= 10; j++) { Button button = new Button("Button " + j); flowPane.getChildren().add(button); } titledPane.setContent(scrollPane); accordion.getPanes().add(titledPane); } // 展开第一个 accordion.setExpandedPane(accordion.getPanes().get(0)); return accordion; }