Question

I am making a chat client with smack. So after logging in I retrieve the roster into my javafx app. In order to listen if my buddies are available I tried to use a listener like this:

            rosterList.addListener(new ChangeListener<ObservableList<RosterDTO>>(){

                @Override
                public void changed(
            ObservableValue<? extends ObservableList<RosterDTO>> observable,
                                ObservableList<RosterDTO> oldValue,
                                ObservableList<RosterDTO> newValue) {
                            rosterList = loginManager.getXmppManager().displayBuddyList();
                            System.out.println("x----" + rosterList.toString()); 

        }   

So, after I entered my code, eclipse returns:

The method addListener(ListChangeListener) in the type ObservableList is not applicable for the arguments (new ChangeListener>(){})

Why is that happening? How should my listener be implemented?

Thanks in advance.

Was it helpful?

Solution

A ChangeListener is not a ListChangeListener.

ObservableList.addListener requires a ListChangeListener as it's parameter.

The JavaFX collections tutorial details how to use ListChangeListeners.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top