0
votes

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.

1

1 Answers

2
votes

A ChangeListener is not a ListChangeListener.

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

The JavaFX collections tutorial details how to use ListChangeListeners.