我已经设法在初始化时创建一个JFoenix tabpane。但是,我不知道如何在选择选项卡时设置某些操作。以下是我的代码!
tabPanel = new JFXTabPane();
tabPanel.setPrefSize(440, 50);
tab = new Tab();
tab.setText("My Events");
tab2 = new Tab();
tab2.setText("Categories");
tab3 = new Tab();
tab3.setText("Suggested Events");
tab3.setId("suggestedEventsTab");
tabPanel.getTabs().add(tab);
tabPanel.getTabs().add(tab2);
tabPanel.getTabs().add(tab3);
VBox tabBox = new VBox();
tabBox.setPrefSize(446, 100);
Pane tabPane = new Pane();
tabPane.setPrefSize(450, 100);
VBox.setMargin(tabPanel, new Insets(33 , 0 , 17 , 0));
tabBox.getChildren().add(tabPanel);
tabPane.getChildren().add(tabBox);
TopPane.getChildren().add(tabPane);
SingleSelectionModel<Tab> selectionModel = tabPanel.getSelectionModel();
//
提前谢谢!干杯
答案 0 :(得分:0)
添加ChangeListener以侦听ChangeEvents
JavaFX TabPane: How to listen to selection changes
http://www.java2s.com/Tutorial/Java/0240__Swing/ListeningforSelectedTabChanges.htm