Short explanation of my problem, I need to parse an object and put its content into a JTree. I know the object can have fields of primitive types, but also other objects. How can I achieve that parsing, is reflection something I should use? I have no clue right now.
The structure would look something like that:
-object1
|
fieldname1 = 1256
|
fieldname2 = 5623
|
object2
| |
| fieldname1 = 154
| |
| fieldname2 = 190
|
object3
|
Any help would be appreciated. Thanks in advance!
Yes, you should use Reflection API to discover object fields, and fill the JTree node values.
Recursively process each object as follows:
Class.getDeclaredFields())Class.getDeclaredFields()doesn’t return inherited fields)