How do I fill an ObservableList from an ArrayList?

0

I am learning to play with JavaFX, I try to make a TableView show the elements of a Database. For that, create a class (Methods) with a method that fills an arrayList (Jewel works with Swing Jtable).

The method returns an ArrayList named list.

How can I make an ObservableList that I have in the controller of the window, fill with this "list" that is obtained with this method ??

    
asked by Gabriel Mc Gann 01.01.2018 в 04:08
source

1 answer

0

Keeping in mind that you are working with a TableView:

ObservableList list = table.getItems();

With the observableList you can now do any of these options:

list.addAll(myArrayList);

or

list.setAll(myArrayList);
    
answered by 04.01.2018 / 20:11
source