这是我的代码:
public class TabApp implements Initializable {
@FXML
Button newButton;
@FXML
TabPane tabPane = new TabPane();
public Tab newTab;
private SingleSelectionModel<Tab> selectionModel;
public int zQueryTabCount = 2;
@FXML
public void handleNewButton(ActionEvent event) {
System.out.println("new button is pressed");
newTab = new Tab();
selectionModel.select(newTab);
newTab.setId("Query " + zQueryTabCount);
newTab.setText("Query " + zQueryTabCount);
tabPane.getTabs().add(tabPane.getTabs().size(), newTab);
tabPane.getTabs().get(0).setClosable(false);
newTab.setClosable(true);
if (zQueryTabCount < 2) {
tabPane.getTabs().get(0).setClosable(false);
}
zQueryTabCount++;
}
}
我正在NullPointerException
排队selectionModel.select(newTab);
我该如何解决?