1

I am not a guru in Java, but I've got a task in which I have to create some tree list with properties, e.g. like this:

depth1
    property1 | checkbox
    property2 | combobox
depth2
    property3 | string
    property3 | button

where for every property it is possible to have different controls. I was struggling with JXTreeTable, but due to lack of documentation I am completely confused whether it is even appropriate for this. Maybe I can achieve this with simple JTreeTable instead of JXTreeTable? That would be even better. Could you suggest me any solution, please?

4

1 回答 1

1

好的。

尝试这个:

创建一个class Property存储属性,如property1 | checkbox

然后创建尽可能多Property的对象并将它们添加到properties list.

然后like和a中put的对应 。keydepth1properties listmap

而已!

属性类:

public class Property {

private String propertyName;
private String controlType;
private String controlValue;

//getter setters

}

放置示例值的代码,例如

深度1

    property1 | checkbox
    property2 | combobox

去这里:

Map<String, List<Property>> myCustomTree = new HashMap<String, List<Property>>();

    Property p1 = new Property();
    p1.setPropertyName("property1");
    p1.setControlType("checkbox");
    p1.setControlValue("TRUE");//may be true/false or checked/unchecked

    Property p2 = new Property();
    p2.setPropertyName("property2");
    p2.setControlType("combobox");
    p1.setControlValue("A String that is contained in my combobox");

    List<Property> properties1 = new ArrayList<Property>();
    properties1.add(p1);
    properties1.add(p2);

    myCustomTree.put("depth1", properties1);

这是你想要的吗?

于 2013-05-22T20:16:58.057 回答