-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).

2
  • what is meant with new ArrayList <Film>[]; did your code compiled even? Commented Mar 9, 2017 at 7:58
  • 1
    Possible duplicate of in java,how to iterate list of objects Commented Mar 9, 2017 at 7:58

2 Answers 2

0

Somthing like this :)

 if(CollectionUtils.isNotEmpty(lsfilm)){
    for (Film film : lsfilm){
       comboBox.add(film.getNameFilm());
    }
    }
Sign up to request clarification or add additional context in comments.

Comments

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);
}

1 Comment

Thanks @dansienmens it should work now with turning only names into an array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.