Create swing component based on property

Viewed 2104

I have a small program, which is able to load components during the runtime. I would like to write a small API for those components. The main program should recognize properties from the component and create for each property a swing component. My idea was to use annotations, something like:

@Property(name = "X",  PropertyType.Textfield, description = "Value for X")
private int x;

What do you think about it? Any problems with that? Are there similar implementations or other options? Thanks for all advices and hints!

Update Please, notice that I'm not able to use third party libraries.

Update I would like to create an abstract class, which is able to create swing components based on the attributes from the concert class. The abstract class controls the presentation. For example (pseudo code):

public class A {
    /**
     * Create swing component based on the concret class
     * In this example class A should create a jTextField with a jLable "Cities". So I have not to create each component manuel, 
     * If the text field changed the attribute for cities should set (My idea was with propertyChangesSupport).
     */
}

public class B extends A {
    @Property(name = "Cities",  PropertyType.Textfield, description = "Number of cities")
    private int cities;
}
4 Answers
Related