This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Im sure this question has probably been asked before, but I cant find an answer that seems to help me, so maybe someone will answer it in a way that does.
Im creating a video store program for a class that I am taking. We just recently moved the program from being all text-based in a console window to using a swing gui. So far what we have is a JFrame that contains two items, a JList and a JButton. The JList contains a list of movies that are hard coded into a class that manages all of the videos. The button brings up a custom JDialog that contains text fields to allow the user to input values for a videos title and director, etc, add therefore add a video with these values to the Jlist. The Dialog also contains a button that, when pressed, uses the getText() method to feed the input values into set methods and the video is created without a problem. The button also sets the JDialog to visibility to false so that it adds the movie and closes, bringing the user back to the main window that contains the JList and JButton, as described before. I can print the video out to the console just fine, so I know that there is no problem in these steps.
The problem is that the list needs to be updated automatically when the JDialog is closed. Im not sure of the best way to do this, or even of a way that works to do this. I thought that maybe I needed to implement a ListListener of sorts, whether is be predefined or custom written, or maybe there was another way to do it, I dont know. I was hoping that someone would be able to give me (a relatively new coder) a few pointers...