aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTree problem with parents Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTree problem with parents" Watch "JTree problem with parents" New topic
Author

JTree problem with parents

Olivier Legat
Ranch Hand

Joined: Nov 17, 2007
Posts: 176

Hello everyone

I've been trying to make a dynamic JTree (something that looks a little bit like this)

Just like with DynamicTree.java I made an addNode method and added 2 more methods.

Adding a canvas works without any problems. But when I invoke removeCanvas I get this aggressive message but strangely enough the node still disappears
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: node does not have a parent.
at javax.swing.tree.DefaultTreeModel.removeNodeFromParent(Unknown Source)
at ueacad.view.explorer.TreeManager.removeNode(TreeManager.java:60)
at ueacad.view.desktop.CanvasFrame.dispose(CanvasFrame.java:54)
at javax.swing.JInternalFrame.doDefaultCloseAction(Unknown Source)
at javax.swing.plaf.basic.BasicInternalFrameTitlePane$CloseAction.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)



Is there something wrong with my add method ? Or does the error come from elsewhere?

Thanks in advance


Olly
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19696
    
  20

Are you trying to remove the root node?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Olivier Legat
Ranch Hand

Joined: Nov 17, 2007
Posts: 176

I don't think so :s ... I'll double-check.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTree problem with parents