Wiki

Clone wiki

propertyTree / Home

PropertyTree

A PropertyTree is a means to organize a set of properties of whatever kind they be.

Contents

What is it?

The default Swing JTree implementation cannot contain graphical components like JCheckBoxes. The default JList implementation hasn't even got an «editable» mode to enable users to change the contents of a list. The PropertyTree aimes at solving these issues by using different JPanels instead of one single JLabel to paint the nodes and cells in a tree. The result is a nice PropertyTree (and a nice PropertyList) that take care of your property hierarchy.

This is what it looks like: screenshot

Who uses it?

Who? Well, NetBeans, for one.

Current release: 4.2

There was released a version tagged 4.2 on sunday, february 16th 2014. Details are found in the changelog. Please do not hesitate to use the issue tracker if you find a bug (or for any other issue).

Installation and Use

A PropertyTree is fairly simple to install and use. Simply have the jar file in your classpath and construct it just like you would construct a JTree:

 // first construct a Property object, which will serve as a tree node:
Property     node   = new Property("Cool", true);

// Then use the Property object in the PropertyTree constructor:
PropertyTree myTree = new PropertyTree(node);

There you go. You now have a PropertyTree already! Next thing to notice is that Property objects and DefaultMutableTreeNodes work seamlessly together:

node.add(new DefaultMutableTreeNode("changeable text, but with no callback"));
node.add(new Property("Property object node", "Surveil changes to this text"));

// If you want a list instead, here's how:
DefaultListModel<Property> model = new DefaultListModel<Property>();
model.addElement(node);
PropertyList myList = new PropertyList(model);

That's all there is to it! You now have a PropertyTree or a PropertyList! To benefit from the magic updating, make sure you have a PropertyController object to receive notification as a property is changed. Assuming you create the Property objects from within the PropertyController, you will construct tree nodes like this:

Property parent = new Property("","Names", this);
parent.add(new Property("First name", "John", this));
parent.add(new Property("Family name", "Doe", this));

The this then refers to the PropertyController. The tree will notify about changes via the propertyChangeCallback method. Put your handling code in there.

Javadoc documentation

This is where you find the PropertyTree API (javadoc).

You might want to look at the changelog too.

Test it

There used to be an applet on the site for immediate testing. It might still be there, back on the old PropertyTree site on java.net (that would be the 3.2 version). Here on Bitbucket, however, to see the PropertyTree in action, you will have to download the jar and do java -classpath PropertyTree-4.2.jar TestPanel

Updated