Hello Everyone.
Im trying to create my new JTree component with fallowing functions:
- reading and showing files from system directory (works)
- showing popup with options after right mouse click at tree node (works)
- added first option to the popup, collapse and expand (works)
---------------------------------------------------------------------------
Now, I would like to add options like create new file/delete file or directory or rename.
Those functions are simple, but one thing is NOT simple for me.
Its obvious that I should refresh/reload my tree after adding/deleting file or renamming it, but..
I found sollution somewhere how to reload my node (update)
There aren't any errors in eclipse, but while
testing it, and for example using this function, i got error:
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: eu.matim.editor.sandbox.jtree.FileSelectorModel cannot be cast to javax.swing.tree.DefaultTreeModel
at eu.matim.editor.sandbox.jtree.FilePreviewer$4.actionPerformed(FilePreviewer.java:115)
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.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$Handler.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.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)
That i cant cast my FileSelectorModel to the DefaultTreeModel.
My FileSelectorModel code is here:
It would be great if someone can help me a bit how to reload my tree or node.
Thanks in advance!