All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.factoryfx.javafx.util.CheckComboBoxHelper Maven / Gradle / Ivy

There is a newer version: 4.0.1
Show newest version
package io.github.factoryfx.javafx.util;

import java.util.function.Consumer;

import javafx.beans.value.ChangeListener;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Skin;

import javafx.scene.control.SkinBase;
import org.controlsfx.control.CheckComboBox;


public class CheckComboBoxHelper {

    //workaround: http://stackoverflow.com/questions/25177523/how-to-listen-to-open-close-events-of-a-checkcombobox
    public static  void addOpenCloseListener(CheckComboBox comboBox, Consumer> listener){
        comboBox.skinProperty().addListener((ChangeListener) (skinObs, oldVal, newVal) -> {
            if (oldVal == null && newVal != null) {
                SkinBase skin = (SkinBase) newVal;
                ComboBox combo = (ComboBox) skin.getChildren().get(0);
                combo.showingProperty().addListener((obs, hidden, showing) -> listener.accept(comboBox));
            }
        });
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy