M
Malte Schneider
Hello there,
I've got a problem using JTree.
I use a subclass of JTree that overwrites getCellRenderer() to get full
control over the cell renders. Furthermore i use my own TreeModel and
TreeNode implementations. These classes read method names and return
values of any object.
The whole thing works fine for most object except for one object/class.
If i try to display the structure and content of the object using my
tree the tree is not displayed correctly. First nothing of the tree is
displayed. But if i click onto it trying to select the hidden nodes some
parts of the trees are displayed but never the whole tree.
My TreeCellRenderer implementations are subclasses of
DefaultTreeCellRenderer and overwrite getTreeCellRendererComponent(JTree
tree, Object value, boolean sel, boolean expanded, boolean leaf, int
row, boolean hasFocus) to determine the current value and call the super
method.
Additionally there's a TreeSelectionListener registered at the JTree
that triggers the display of extra information on a separate JPanel.
While selecting node the following exception is written onto the
console without killing the application:
java.lang.NullPointerException
at
javax.swing.plaf.basic.BasicTreeUI$MouseHandler.handleSelection(BasicTreeUI.java:2847)
at
javax.swing.plaf.basic.BasicTreeUI$MouseHandler.mousePressed(BasicTreeUI.java:2824)
at
java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:222)
at java.awt.Component.processMouseEvent(Component.java:5097)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3195)
at
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:480)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at
java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
I tried to find answers using Google but every hit talks about a
TreeExpansionListener calling updateUI though i don't use this in my code.
I hope anyone knows how to fix the problem.
Thx, Malte
I've got a problem using JTree.
I use a subclass of JTree that overwrites getCellRenderer() to get full
control over the cell renders. Furthermore i use my own TreeModel and
TreeNode implementations. These classes read method names and return
values of any object.
The whole thing works fine for most object except for one object/class.
If i try to display the structure and content of the object using my
tree the tree is not displayed correctly. First nothing of the tree is
displayed. But if i click onto it trying to select the hidden nodes some
parts of the trees are displayed but never the whole tree.
My TreeCellRenderer implementations are subclasses of
DefaultTreeCellRenderer and overwrite getTreeCellRendererComponent(JTree
tree, Object value, boolean sel, boolean expanded, boolean leaf, int
row, boolean hasFocus) to determine the current value and call the super
method.
Additionally there's a TreeSelectionListener registered at the JTree
that triggers the display of extra information on a separate JPanel.
While selecting node the following exception is written onto the
console without killing the application:
java.lang.NullPointerException
at
javax.swing.plaf.basic.BasicTreeUI$MouseHandler.handleSelection(BasicTreeUI.java:2847)
at
javax.swing.plaf.basic.BasicTreeUI$MouseHandler.mousePressed(BasicTreeUI.java:2824)
at
java.awt.AWTEventMulticaster.mousePressed(AWTEventMulticaster.java:222)
at java.awt.Component.processMouseEvent(Component.java:5097)
at java.awt.Component.processEvent(Component.java:4897)
at java.awt.Container.processEvent(Container.java:1569)
at java.awt.Component.dispatchEventImpl(Component.java:3615)
at java.awt.Container.dispatchEventImpl(Container.java:1627)
at java.awt.Component.dispatchEvent(Component.java:3477)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3195)
at
java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)
at java.awt.Container.dispatchEventImpl(Container.java:1613)
at java.awt.Window.dispatchEventImpl(Window.java:1606)
at java.awt.Component.dispatchEvent(Component.java:3477)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:480)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at
java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
I tried to find answers using Google but every hit talks about a
TreeExpansionListener calling updateUI though i don't use this in my code.
I hope anyone knows how to fix the problem.
Thx, Malte