• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTree CellRenderer weird problem  RSS feed

 
Makesh Kumar Ramakrishnan
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to display multiple lines whenever needed in the JTree. So I implementd my own MultiLineCellRenderer. Its working fine with my example program. MultiLineCellRenderer extends JTextArea and implements TreeCellRenderer.

The main function of my example program is


In the above program SpecViewValues(extends JPanel) is the class which builds JTree and uses the MultiLineCellRenderer. This Example program works fine as expected(multiple lines displayed).


But when I tried to integrate the SpecViewValues with my application, it behaves differently(multiple lines not displayed and also there is no indication that MultiLineCellRenderer is used in the JTree build up) . The same data set is used in the main application too. The main application has the object hierarchy as JFrame --> JInternalFrame --> JTabbedPane --> JPanel -->JTree.

But my example program object hierarchy is JFrame --> JTabbedPane --> JPanel --> JTree.

Why MultiLineCellRenderer behaves differently in two programs when the two programs are almost identical..

Note: I tried my best to elaborate the problem I have, in few lines. I might have missed some points you needed to understand the problem. In that case, please post your questions. I will try to explain.

Thanks,
 
Makesh Kumar Ramakrishnan
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help to solve the above mentioned problem. Its urgent.


Thanks,
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> So I implementd my own MultiLineCellRenderer.

very difficult to offer any help, or suggestions, when we are dealing with the unknown
 
Makesh Kumar Ramakrishnan
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael for your reply. I found the cause of the problem. I was about to post the reply here.

Here is my finding. There is nothing wrong with TreeCellRenderer implementation. The MultiLineCellRenderer(implementation of TreeCellRenderer) works for MetalLookAndFeel. In my example program, i didn't set the LookAndFeel. so the default LookAndFeel is MetalLookAndFeel and it works fine. But In my application, I set the LookAndFeel to WindowslookAndFeel. Thats the problem. The customized MultiLineCellRenderer fails for other LookAndFeels, except MetalLookAndFeel.

I hope, this finding might be helpful for others.

Thanks,
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!