I'm working on creating a GUI application (in particular, a sensor responsive system). So you can imagine the system having a list of possible responses to execute when a set of conditions are met. To start, I have created a bunch of default responses (each a separate Java class subclassed from an abstract base class) but I would like to maintain the ability for future developers to create their own custom responses and have them included in the system without having to modify the original source.
So if I want to present to the operator (or user of the system) a list of available responses (in the GUI as a JComboBox), what's the best way for that list to be generated without hard coding the list in the original source? I thought of using a combination of directory scanning (looking for class files that meet a certain name) and reflection to create the necessary response classes.
Is this the best approach, or have I missed something?
I might be missing the complexity of your question, but it seems to me you would want a separate "Model" class that extends DefaultComboBoxModel. This would read in the values for the JComboBoxes dynamically, either from a database, an XML file, or whatever. Then, the other developers could just modify the data source and not the code. [ August 22, 2005: Message edited by: Tim McGuire ]