aspose file tools
The moose likes Swing / AWT / SWT and the fly likes Creating GUI lists dynamically Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "Creating GUI lists dynamically" Watch "Creating GUI lists dynamically" New topic
Author

Creating GUI lists dynamically

David Irwin
Ranch Hand

Joined: Mar 25, 2004
Posts: 82
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?

Thanks,
Dave
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 819

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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating GUI lists dynamically
 
Similar Threads
Why an IDE?
Design issues with local-remote Data class
Please let me know how to create a class dynamically using reflection. No rush.
Unit testing class that deals with file I/O
File Exists Wildcard