It is impossible to specify tree in jtree widgets.
Only adding root node works without problem:
jtree .tree
.tree node add root "Root node"
Now when I try to add other nodes command failed
.tree node add 0 "First node"
Error message:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: node has no children
at javax.swing.tree.DefaultMutableTreeNode.getChildAt(DefaultMutableTreeNode.java:228)
at com.onemoonscientific.swank.SwkJTreeWidgetCmd$NodeAdd.run(SwkJTreeWidgetCmd.java:210)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
As I discovered in source there is no possibility to add nodes which follow root node - I temporary modify in SwkJTreeWidgetCmd.java method run of NodeAdd class:
"for" loop (over iNodes for calculating refNode) is executed only when iNodes[0]>=0,
patch is follow (don sure that I made it in right way because I done it under windows with WinMerge utility)
206a207
> if (iNodes[0]>=0) {
209a211
> }
Now these commands work
.tree node add -1 "First node"
.tree node add -1 "Second node"
.tree node add -1 "Third node"
.tree node add 0 "Second level node"
.tree node add {0 0} "Third level node"
My version of SwkJTreeWidgetCmd.java file is included as attachment