JavaFX TabPane: How to listen to selection changes

前端 未结 4 1228
温柔的废话
温柔的废话 2021-01-03 23:47

I want to do some actions when user goes from one tab to another, since i made my form design with Scene Builder I cannot use code mentioned here (He used TabPaneBuild

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-04 00:31

    Or in Java 8 using lambda expression....

    chatTabs.getSelectionModel().selectedItemProperty().addListener((ov, oldTab, newTab) -> {
            System.err.println("changed");
        });
    

提交回复
热议问题