From: Kevin M. <qk...@lm...> - 2001-07-17 08:38:56
|
Thanks for all the help so far. I am trying to use a tree in a splitpane. I am using the Java Swing tutorial on trees as a reference http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html According to this, if I add a custom object to the tree I must implement it's toString method. But it doesn't seem to work: from pawt import swing Node = swing.tree.DefaultMutableTreeNode class CustomObject: def __init__(self, key, value): self.key = key self.value = value def toString(self): print "toString: ", self.key return self.key top=Node("Test") top.add(Node(CustomObject("key","value"))) tree=swing.JTree(top) frame=swing.JFrame() frame.getContentPane().add(tree) frame.visible=1 _________________________________________________ Name/Title : Kevin McNamee, Software Consultant Phone : +46 13 32 1165 E-Mail : kev...@er... |