JavaFX布局-Accordion

avatar
作者
筋斗云
阅读量: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;     } 

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!