I have a JTree that I'm filling with skills for a Game Database programme that I'm writing.
There are several categories, and subcategories (actual skills), and then levels skill below that (sometimes). Currently I'm emulating this with one skill class, some options inside, and a few enums, plus a method to check that if the skill is a category (called isCategory). Two other things to note:
- Different types of skill behave differently.
Some are bought once, other several times, some have options to pick from etc - Different categories contain different skill.
For instance The Weapon Skills category has different types of weapons, but the Armour Skills are in a different section.
I've seen a very good example of attaching a ComboBox via a cell renderer to each node in the tree. Here is the example I found.
I understand the above code, but I can't see how to would attach the combo box to a node, and not to the tree? I've read 'How to use Trees', and I've run, and looked at the code for a few of the demos for tree. I can make basic trees, but I find the tutorials a bit obtuse and lacking in enough detail to figure out for myself how to proceed. I've found another example of only rendering leaf nodes as checkboxes, which is much more complex.
Obviously I'd like to combine the two, being able to have different categories able to have different skills and different skills have different levels of proficiency. However the only way I can think of doing so it to have different JComboBoxModels for the different types but I don't know how to do this, and I can't find out how. I've tried to edit the checkbox example to use ComboBoxes, but for the life of me I can't figure it out.
Could someone give me a hint as to what approach to take on this, as I'm new to Java and strugglingto figure out what to do?