• Post Reply Bookmark Topic Watch Topic
  • New Topic

ToolTipText

 
Joe Myn
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I show part of the contents of a file as a JTree node tooltip.


public class CustomTreeCellRenderer extends DefaultTreeCellRenderer
{

public CustomTreeCellRenderer()
{

super();
}


public Component getTreeCellRendererComponent(JTree tree, Object value,
boolean selection, boolean expanded,
boolean leaf, int row, boolean hasFocus)
{
super.getTreeCellRendererComponent(tree, value, selection, expanded,
leaf, row, hasFocus);


DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;



Object tooltip = node.getUserObject();
setToolTipText(tooltip.toString());

return this;

}

}

What is showing is the file name.
I need to display its contents.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!