-1

I have FilmDAO which have List getAllFilm(), in the main i have :

List <Film> lsfilm = new ArrayList <Film>();
lsfilm = FilmDAO.getAllFilm();

My question is how to fetch the list objects one by one, and get only the name of the movie (nomFilm) so i can add it in the Choice list (ComboBox).

hizaoui
  • 3
  • 2
  • what is meant with new ArrayList []; did your code compiled even? – mhasan Mar 09 '17 at 07:58
  • 1
    Possible duplicate of [in java,how to iterate list of objects](http://stackoverflow.com/questions/6007429/in-java-how-to-iterate-list-of-objects) – santosh gore Mar 09 '17 at 07:58

2 Answers2

0

Try a for-each loop to add the film names to your ComboBox.

for (Film f : lsfilm){
   String filmName = f.nomFilm;
   myComboBox.addItem(filmName);
}
dansiemens
  • 191
  • 2
  • 7
0

Somthing like this :)

 if(CollectionUtils.isNotEmpty(lsfilm)){
    for (Film film : lsfilm){
       comboBox.add(film.getNameFilm());
    }
    }
Younes Ouchala
  • 243
  • 4
  • 13