JAVAFX - unable to add items to listview


I have a Tab called chat. Inside this Tab I have a list of users as ListView<string>. The content of this ListView was loaded from FXML file using:


I am trying to add items to my listview using java, but when I open the GUI, chat tab, the items I add does not get displayed in the users listview.

One of the ways I tried was:

List<String> values = Arrays.asList("one", "two", "three");

I have tried other ways as well, but nothing seems to work. I'd appreciate your help.

6/30/2015 4:39:17 AM

Accepted Answer

thanks guys..
the problem was that my listView of users was created by the FXML loader, and then by mistake i initialized it again in the java code, so all was needed is deleting the row:

listOfUsers=new ListView<String>();
3/17/2013 2:29:41 PM

the file chat.fxml has fx:controller?!

You need...

xmlns:fx="" fx:controller="DIRECTORY.FILE" //

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow