I'm making an application that allows users to view task lists stored in different databases. So what happens is that, I have a list of the names of browsable databases (stored as a text file). Program loads the first database in that list and displays contents. Then from a menu, I allow users to select another database in the list. (Kind of like, I want to view the tasks for Andy, and now Bob, and now Carl...).
Problem is, I don't know how to update the UI so that the contents of the new database is displayed. It's trivial to remove the tasks currently listed, read from the DB, and then repopulate. But I can't get to this code (from my Singleton database driver) because I would need access to the instance of my Runnable which was loaded to the EventQueue (all my JComponents are private, as with all tutorials I've so far encountered). I'm looking at the get/peek methods in EventQueue but they don't seem to be what I need since they return AWTEvents and I don't see any relation between AWTEvent and Runnable other than java.lang.Object.
So, is it possible to get the current Runnable? How?
Thanks in advance for any guidance.
I suspect that you are going about this wrong. What you want to do is change databases from within a control class (using MVC nomenclature). For instance, say you load the available databases into a JList, then in the control for this component, say a ListSelectionListener, you execute a SwingWorker that loads the new database and then displays the results in the GUI either via its publish/process pair of methods or in the done method. The database code (the model) should know nothing about the view or GUI portion of your code (the Runnable as you call it).