JavaFX: How to set a TiteledPane selected/opened by default

旧城冷巷雨未停 提交于 2019-12-05 04:03:42

About the code difficulties it's highly recommended to refresh your project everytime you work on then save an FXML file from javaFX scene builder because eclipse dont do that automatically.

if you still hve some code problemes,this exemple is verified:

@FXML
private Accordion accord;
@FXML
private TitledPane pane1,pane2;

//codes in controller.intialize()
...
    pane1.setText("TitledPane A");
    pane2.setText("TitledPane B");
    accord.setExpandedPane(pane1);

And about the cloud problem you mentioned in the comment, as i know there is no harm on putting the workspace in google drive folder.May be it would be better if you do backup every time you finish a chapter of code, because sometimes drive crash when he try to load a file already used by another program.

For those who want to include the default expanded pane in the FXML rather than in code:

<Accordion expandedPane="$myPane">
    <panes>
      <TitledPane fx:id="myPane">
          ...
      </TitledPane>
      <TitledPane>
          ...
      </TitledPane>
    </panes>
</Accordion>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!