Question

This is really confusing me. I will show my code so far. I am trying to make certain field's editable. That is the end goal, but I just tried to put in a JCheckBox just to test. But even that doesn't seem to work.

Can you please take a look at this. I would really appreciate it.

All the JXTreeTable does is make my nodes editable. which I don't want as well as if I do change my node, its edit will save through the whole row which too I don't really want.

Here is what I have done:

Intialization

JXTreeTable table = new JXTreeTable(Shared.model);
table.setDefaultEditor(Object.class, new ComplexCellEditor());
table.setRootVisible(false);
table.setEditable(true);
table.getColumnModel().getColumn(0).setPreferredWidth(200);
table.setColumnControlVisible(true);

This is my ComplexCellEditor.java

class ComplexCellEditor extends DefaultCellEditor{
public ComplexCellEditor() {
    super(new JTextField());
    Console.t("here");
}
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean a, boolean b, int row)
{
    Component component = super.getTreeCellEditorComponent(tree, value, isSelected, a , b, row);

        Console.t("here");   <--**//THIS DOESN'T EVEN GET PRINTED**
        JCheckBox chk= new JCheckBox();
        return chk;
}

}

Thank you for your time and effort.

Was it helpful?

Solution

Make sure your TreeTableModel returns true for isCellEditable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top