Hi,
I am trying to create a custom node (a node with a jlabel and a textfield) for a a JTree. I am not entirely sure how to accomplish this, so I a certain route. I tried to create a custom class that extends JLabel and implements TreeNode. Is this the way to do it? If it is, I can't compile because of override error. Look at the code:
public class Node extends JLabel implements TreeNode {
private JLabel label;
public Node () {
label = new JLabel("TESTST");
}
public Enumeration children() { return null; }
public boolean isLeaf() { return true; }
public boolean getAllowsChildren() { return true; }
public int getIndex(TreeNode node) { return 0; }
public TreeNode getParent() { return null; }
public int getChildCount() { return 0; }
public TreeNode getChildAt(int childIndex) { return null; }
}
The problem is the getParent() method. This method is defined in java.awt.Component, and I can thus not override it because there is an incompatible returntype. Is there a way around this? Creating a custom tree is confusing.
Edited by: Siniz on Apr 27, 2008 4:47 AM