Question

i try to remove a filter because I get the error: Widget is disposed.

My Filter:

disp.addFilter(SWT.KeyDown, new Listener() {

        public void handleEvent(Event e) {
            if(disp.isDisposed()){
                disp.removeFilter(SWT.KeyDown, this);
            }

            if (e.keyCode == SWT.CR) {
                       //....
            }

        }
    });

But I get the message even with the isDisposed If. I think I have to put it in the cancel and in the OK Buttons. But how do I get the listener?

Était-ce utile?

La solution

You are trying to removeFilter from an already disposed widget. Try this:

    if(!disp.isDisposed()){ // not disposed
        disp.removeFilter(SWT.KeyDown, this);
    }
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top