Re: [SWING] Problem with JTree
- From: Daniele Futtorovic <da.futt.newsLOVELYSPAM@xxxxxxxxxxx>
- Date: Tue, 12 Feb 2008 09:18:14 +0100
On 2008-02-11 20:59 +0100, Malte Schneider allegedly wrote:
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.
Read the source code! It's part of the JDK (src.zip; normally accessible
through your IDE). Open the source for BasicTreeUI, go to line 2847,
look what it's trying to do. This should get you started.
I would have loved to learn the answer myself, unfortunately, the code I
see on my machine in BasicTreeUI:2847 cannot possibly throw an NPE. I
conclude that you're not using the same version as I am (1.6.0_04).
Which version are you using?
DF.
.
- References:
- [SWING] Problem with JTree
- From: Malte Schneider
- [SWING] Problem with JTree
- Prev by Date: Re: Tool for inlining useless getter/setter call
- Next by Date: Re: Tool for inlining useless getter/setter call
- Previous by thread: Re: [SWING] Problem with JTree
- Next by thread: Java NIO selector close idle connections?
- Index(es):
Relevant Pages
|