Editor for data object in swing, what is the simplest way?

I have a java object with multiple members. I want to create a small, quick and dirty editor that allows me to easily set the value of elements. I created a panel containing a TextField for each member. I have a setValues ​​() method that takes the value of TextFields and sets them to an object. This method is automatically called when I call getDataObject () from the panel. Some of the members contain strings, some others are doubles, and some are integers. Nothing unusual.

The question, however, is what would be an easier way to improve this group? How do I add some validation without having to manually validate each value? How can I do this without having to write a huge amount of code? Currently my quick and very dirty implementation is just throwing a RuntimeException, but of course this is temporary.

Before I decided to write all this code, I wondered what the best template would be, or if there is any library available to perform such operations, as this seems to be a fairly common use case. In other words, if there is a lazy way out.

+1


source to share


2 answers


Quihubole Mario! :)

I once read about this library from JGoodies, but honestly I don't know if it's related or not.



JGoodies Binding

Take a look at her and see if she helps.

+1


source


Have a look at the property editor at http://www.l2fprod.com/common/



+1


source







All Articles