I am new to Java and trying to create a cataloging program as a beginning exercise. I’ve made the interface and I can populate the initial JComboBox with the titles the way I want but my issue comes with storing the rest of the data so that it can be easily retrieved based in the title from the JComboBox.
My xml looks something like this:
<Movies>
<Movie>
<Title></Title>
<Studio></Studio>
<Director></Director>
<Actors></Actors>
<Rating></Rating>
<Stars></Stars>
<Review></Review>
<Synopsis></Synopsis>
<Genre></Genre>
</Movie>
</Movies>
with multiple movie elements. I want to store the data for each movie in some form of array so that I can populate the rest of the form fields with the proper data when a user selects a title from the JComboBox. But I can’t decide on a good array type to do this. It seems to me I need some kind of array that looks like this:
Array<"Title1" -> "Title", "Studio", ....;
"Title2" -> "Title", "Studio", ...;
and so on...>
I’ve been looking into different arrays like Hashmaps, ArrayLists, Multi-Dimensional String Arrays and maps but none of these seem to do what I’m thinking.
I’d really appreciate your thoughts on this.
Why don’t you create a class
Moviewith fields for Title, Directory, Actors, etc? You can then have a list containing all your movies.If the movies are uniquely identifiable by their name, you can put them in a HashMap with the name of the movie as the key and the
Movieobject as the value.