Issue Details (XML | Word | Printable)

Key: SWANK-1
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: tsib
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
swank

Adding items (nodes) to jtree widget doesn't work

Created: 03/Oct/10 06:09 PM   Updated: 03/Oct/10 06:13 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. Java Source File SwkJTreeWidgetCmd.java (7 kB) 03/Oct/10 06:09 PM - tsib

Environment:

OS: Windows XP
SWANK under Jacl 1.3.2
JDK: build 1.6.0_21-b07


Tags:


 Description  « Hide

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



There are no comments yet on this issue.