Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.


+15 votes
asked in CSC305 Fall 2022 by (1 point)

4 Answers

+9 votes

So we have to remove the movie from the list, our data structure, and movie list viewer. So you need to figure out a way to access the list. It’s similar to the code in initialize method in MovieListController class.

answered by (1 point)
+9 votes

My way is to get the index of the movie you want to delete directly from the list.

The onAction method for that DeleteMovie could be added/modified in the MovieListController.

The problem is how to get the index:
- You could use both getSelectionMode() and getSelectedIndex() to access the index of each movie in the list.
- When you have its index, try getItems() to get all the information of movie and remove them from the list view with the index you have

That way worked for me and also help me avoid WET code of repeating the listView multiple times.
Hope this helps!

answered by (1 point)
+7 votes

You may want to find a way to get the selected movie and find another way to remove it

answered by (2.1k points)
+7 votes

First, you want to be able to delete the movie that is "selected."
Then you want to remove the movie that is selected from the movie list where the movies and their info are stored. Also, you want to remove the movie from the list view on the window. Furthermore, you want to think about how to handle the button when a movie is not selected. Then assign this method to the action for the delete button in scenebuilder.

answered by (1 point)