In this tutorial Jtree occupates whole column, but I need a new Tree in any cell of the table.
I know, I need to implement Renderer, and I did.
Like this :
class TreeRenderer implements implement TableCellRenderer { /* bla-bla */}
And my tree was rendered, but the height of the cell did not change and only first tree node (that feets the cell size) was rendered. As far as I know you cannot change the height of a single row or cell in the JTable. And I think this problem is.
Does any one know, may be there is some addon labrary, based on Swing, that can solve this problem?
There is a method to set the rowheight of a single row in a JTable.
table.setRowHeight(int row, int height)
The JTable didn't know if you click on a node in your tree so you need a TreeWillExpandListener to set the right height.
public void treeWillExpand(TreeExpansionEvent tep) {
/* set the rowheight of the clicked tablerow depending on the nodes that will displayed after the treeexpansion*/
// same in treeWillCollaps()
}
But without a TableCellEditor that returns the JTree nothing works.
two methods are important :
private JTree tree;
// some other code ...
// Object during editing
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row,
int column) {
tree = (JTree) value;
return tree;
}
/**
* returned the object after editing
* @return Object
*/
public Object getCellEditorValue() {
return tree;
}
this should solve the problem
Message was edited by:
Olek
Message was edited by:
Olek