text: Q:
  
  Modify JTree nodes appearance
  
  I'm trying to visualize a JTree node as a JButton, I already tried creating a DefaultMutableTreeNode with a Jbutton object and the added it to the JTree:
  JButton button = new JButton("Thing");
  DefaultMutableTreeNode root = new DefaultMutableTreeNode(button);
  JTree alberoClassi = new JTree(root);
  
  These only show an error line with black parameters.
  Searching the net I only found that I need a TreeRendererCell class, but none of the results show how to use it.
  Are there some tutorials where I can find some examples to accomplish the task?
  
  A:
  
  Finally I managed to solve the problem using an external class which implements the javax.swing.tree.TreeCellRenderer interface.
  public class ClassCellRenderer implements javax.swing.tree.TreeCellRenderer {
  
  JLabel className = new JLabel(" ");
  JButton renderer = new JButton();
  DefaultTreeCellRenderer defaultRenderer = new DefaultTreeCellRenderer();
  
  public ClassCellRenderer() {
      renderer.add(className);
  }
  
  @Override
  public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
      Component returnValue = null;
      if ((value != null) && (value instanceof DefaultMutableTreeNode)) {
        Object userObject = ((DefaultMutableTreeNode) value).getUserObject();
        if (userObject instanceof String) {
            String e = (String) userObject;
            className.setText(e);
        }
        returnValue = renderer;
      }
      if (returnValue == null) {
        returnValue = defaultRenderer.getTreeCellRendererComponent(tree, value, selected, expanded,
            leaf, row, hasFocus);
      }
      return returnValue;
  }
  }
  
  The JLabel and JButton could be changed with any other Component needed.
  To add the renderer to the Tree, I used these lines:
      alberoClassi = new JTree(root);
      TreeCellRenderer renderer = new ClassCellRenderer();
      alberoClassi.setCellRenderer(renderer); //aggiunta del renderer per i nodi
  
  