exclude JavaFX Event - Java JavaFX

Java examples for JavaFX:Introduction

Description

exclude JavaFX Event

Demo Code


import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Predicate;
import javafx.beans.property.ObjectProperty;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.event.EventType;

public class Main{
    public static <T extends Event> EventHandler<? super T> exclude(
            EventHandler<T> handler, EventHandler<?> subHandler) {
        if (handler instanceof CompositeEventHandler) {
            return ((CompositeEventHandler<T>) handler).without(subHandler);
        } else if (handler.equals(subHandler)) {
            return empty();
        } else {//w w  w. j av  a2 s  . c o m
            return handler;
        }
    }
    static <T extends Event> EventHandler<T> empty() {
        return EmptyEventHandler.instance();
    }
}

Related Tutorials