Archive for March, 2009

Dynamic GUI through Java Bean introspection

For yet another part of my dissertation project, it recently became evident to me that I would benefit from having the mobile part of my application to auto generate GUI forms. These forms would be based on the properties of  Java beans. Yet again Java came to the rescue through its beans introspection API. The introspection API allows you to not only inspect the properties of a Java bean but also to discover and call the methods (read/write) that are associated to those properties.

Instead of boring you with the details I have uploaded a quick and commented example of using this API in order to be able to build dynamic GUI’s based on the fed Java Beans. This is only a basic example and currently only deals with String and Integer values though this can easily be adapted to deal with more and complex data types by changing the readProps() and writeProps() methods.

Example Dynamic GUI’s from Java Beans (Netbeans) Project Download

Or, individual sources

http://paulcarey.co.uk/releases/dynamicguiexample/DynamicGui.java

http://paulcarey.co.uk/releases/dynamicguiexample/Company.java

No Comments