After all, we always end at managing hierarchical structures - be it a class hierarchy of a program, or the program itself built from different modules connecting you to an "internal world" (GUI, DB connection, data bound business logic, etc.). But this is philosophy, how should it work in your case?
You have nodes in this tree, each item is an "object instance"; while their behavior (where you can put them, the list of allowed child nodes, etc) is common for some sets, like "classes". Yes, this is just like a program code. If you know Java reflection enough, you can even use POJO classes and inheritance hierarchy to build this component, with an IoC container or a factory mechanism to build the actual instances. But I think you don't want that, because that is a heavy language hacking, so...
First, create a "class" object that will describe the behavior of the items. That contains class identifier, "field" names and the allowed types and count of items, etc.
Example: the "root" class is "Player Properties", have "Physical/Mental", "Medical", "Weapons" field. This type is "final": right now you don't want to have different player types. Hint: later on you can do it, using the same tools to handle "non-human monsters"... :-)
The "Medical" field is
- "singleton": the player can't have multiple "Medical" information
- the child type is fixed, only object of "Medical" type can be used here
- required: when you create a player, it must have a "Medical" field
Contrary: Weapons member is not required, it should be created when the first weapon is added to your player. This means: when you "edit" your "object" (now the player), and want to allow adding a new item to it, you should not limit the selection by the actual properties of the instance (which now does not contain "Weapons"), but show all fields of the class definition, and lazily create the new field (child node) when first used. This will create an extensible environment. Later, you can add "Friends" field with multiple player... er... references (see later).
Follow the process with the actual "classes". It will help you refine your ideas, like: it seems better to separate weapon types (swords, daggers, bows, ...), handle ammo somehow (knowing that perhaps the player does NOT have a bow but can collect arrows, but using certain weapons require and decrement ammo, some of them can be found, others are lost...) under "Weapons" class: it is easier to survey, and also show if your player only carries that item or can use it as well (has the skills). On the other hand: you surely will change this structure later on, as you develop your game.
Create a globally available "class store" that you initialize when your game starts, and serve the class definitions when anyone refers to their name. The class def objects must be immutable in this case.
"Objects" are easier: they can be derived from the same root class that contains a reference to the class definition, and generic access to the fields as well. Perhaps use a HashMap to contain those children, identified by the field name. Remember: some of those fields contain a single object, others a set of objects. These instances are mutable of course.
Now for the interface. First, you should check the JTree tutorial..., and it now should be obvious. Each "object" can be represented by a DefaultMutableTreeNode, the "userObject" of the node should be your object (I think the toString() of that node is displayed as the label of the node, but you can create custom cell formatter). Whenever you open a node, you browse the fields of the object, and create child nodes under the parent (if you want to do it dynamically) - or browse the whole tree and build the TreeNode structure when you display the JTree (hint: there is a JTree constuctor with a TreeNode parameter).
When you select a node in the tree, you have the Object instance. By its class, you can display a proper editor panel, or a generic one generated by the class definition (like: tab panels with the fields, editors for the actual field by the field declaration: a button that creates a child of the proper type of lets you select one of the available classes; and editor fields for that instance, like weapon properties). After modifying the structure, you must refresh the tree itself - the TreeModel and its fire...change functions are your friends.
Looks nice? Or too complex? Well, this is a small fraction of the story. I have not talked about
- the class definition hierarchy / or categorization. You better use one of them when you will support adding different classes to the same field (like different kinds of swords). A pro for categorization: a class can have multiple categories, not a fixed inheritance tree, a good stuff when you want to collect "all skills" of a player when spending the XP on skill improvements... :-)
- persistence support: you have to create a generic solution to store the object hierarchy externally, like in a properties or JSON file. Use a human readable format, NO binary serialization, if you want to keep your brain in good shape.
- instance storage: you will soon realize that the "world" of your game is better to be kept in one place. A certain sword is NOT a property of your player, but an entity in the world in your game (the player can lose it, someone can find it, etc), so many of these "objects" in your tree are actually REFERENCES to entities (while others, like the health of the player are really only attributes). You will have to separate the two types, have a global storage for the instances that can resolve references. This will also save you when serializing the game state, and multiple entities refer to the same other entity (like the "Location" of multiple players to the same temple).
- (and to mention the real brain grinder: the similarity of the class storage and instance storage; the fact that type declaration can be object instances themselves in the same way as your program components, active windows, user sessions, etc. This is the land of maniacs like me.)
Anyway, I hope you can use something of this warmup session.