Using this manual (http://www.comp.nus.edu.sg/~cs3283/ftp/Java/swingConnect/tech_topics/tables-trees/tables-trees.html) I'm trying to create tree table for my project's Swing user interface.
In constructor of my class for table I redefined render like this:
public class JTreeTable extends JTable {
public JTreeTable(ITreeTableModel treeTableModel) {
super();
...
setDefaultRenderer(ITreeTableModel.class, tree);
...
}
}
where treeTableModel is my implementation for
interface ITreeTableModel extends TreeModel
In result table looks near to what I want, but I have couple issues:
Field (ID) in my code defines as Object but really it represents numbers (1,2,3 and so on). How to change representation of field ID?
Nodes in my table do not expand. But
public int getChildCount(Object parent_object_id)
returns number > 0
p.s. I know that there is maybe not enough information for direct answer, but I need at least direction in which I can to continue my investigations.
JTree
will use thetoString
method of the node to generate the output. You can either change what thetoString
method returns or use aTreeCellRenderer
(preferably) – HungerfordOutline
. – Georgeannageorgeanne