Issue
I'm trying to do something when one tab of my tabPane is clicked, I've tried use Action Event but it doesn't work:
public void tabPressClicked (ActionEvent event){
comboBoxPresYear.setVisible(true);
lblPresYear.setVisible(true);
}
[EDITED]
The right way to do that:
tabPresentation.setOnSelectionChanged(new EventHandler<Event>() {
@Override
public void handle(Event t) {
if (tabPresentation.isSelected()) {
comboBoxPresYear.setVisible(true);
lblPresYear.setVisible(true);
}
}
});
Solution
I'm not sure what you're trying to do/ what ActionEvent you are expecting but try either something like:
tabPane.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> ov, Number oldValue, Number newValue) {
// do something...
}
});
if you want to do something when the selection changes (any tab)
or try:
for a specific tab (I haven't tried this yet, though).
Answered By - Puce