Having a JTextArea as a node of a JTree

Main.java:

import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.tree.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.net.*;
 
public class Main extends JFrame
{
   public Main() {
      DefaultMutableTreeNode root = createNodes();
      JTree tree = new JTree(root);
      //tree.setCellEditor(new DefaultCellEditor(new JTextField())); 
      tree.setCellRenderer(new DelegateDefaultCellRenderer());
      tree.setRowHeight(-1);
 
      getContentPane().add(new JScrollPane(tree));
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
            System.exit(0);
         }
      });
   }
 
   public static DefaultMutableTreeNode createNodes() {
      DefaultMutableTreeNode root = new DefaultMutableTreeNode("Java");
      
      DefaultMutableTreeNode j2se = new DefaultMutableTreeNode("J2SE");
      DefaultMutableTreeNode j2ee = new DefaultMutableTreeNode("J2EE");
      DefaultMutableTreeNode j2me = new DefaultMutableTreeNode("J2ME");
 
      j2se.add(new DefaultMutableTreeNode("http://java.sun.com/j2se/"));
      j2ee.add(new DefaultMutableTreeNode("http://java.sun.com/j2ee/"));
      j2me.add(new DefaultMutableTreeNode("http://java.sun.com/j2me/"));
 
      root.add(j2se);
      root.add(j2ee);
      root.add(j2me);
 
      return root;
   }
 
   public static void main(String []args) {
      Main main = new Main();
      main.setSize(400, 400);
      main.setVisible(true);
   }
}
 
class DelegateDefaultCellRenderer extends DefaultTreeCellRenderer 
{
   TextAreaRenderer taRenderer = new TextAreaRenderer();
 
   public DelegateDefaultCellRenderer() {
      taRenderer.setBackgroundNonSelectionColor(getBackgroundNonSelectionColor());
      taRenderer.setBackgroundSelectionColor(getBackgroundSelectionColor());
      taRenderer.setTextNonSelectionColor(getTextNonSelectionColor());  
      taRenderer.setTextSelectionColor(getTextSelectionColor()); 
   }
 
   public Component getTreeCellRendererComponent(JTree tree, Object value,
                                  boolean selected, boolean expanded, boolean leaf,
                                  int row, boolean hasFocus)
   {
      if (!leaf) {
         return super.getTreeCellRendererComponent(tree, value, selected, 
                                                   expanded, leaf, row, hasFocus);
      }
      else {
         return taRenderer.getTreeCellRendererComponent(tree, value, selected, 
                                                        expanded, leaf, row, hasFocus);
      }
   }
}   
 
class TextAreaRenderer extends JScrollPane implements TreeCellRenderer
{
   JTextArea textarea;
   Color backgroundNonSelectionColor;
   Color backgroundSelectionColor;
   Color textNonSelectionColor;
   Color textSelectionColor;
 
   public TextAreaRenderer() {
      textarea = new JTextArea(3, 40);
      textarea.setLineWrap(true);
      textarea.setWrapStyleWord(true);
      textarea.setBorder(new TitledBorder("This is a JTextArea"));
      getViewport().add(textarea);
   }
 
   public void setBackgroundNonSelectionColor(Color c) {
      this.backgroundNonSelectionColor = c;
   }
 
   public void setBackgroundSelectionColor(Color c) {
      this.backgroundSelectionColor = c;
   }
  
   public void setTextNonSelectionColor(Color c) {
      this.textNonSelectionColor = c;
   }
  
   public void setTextSelectionColor(Color c) {
      this.textSelectionColor = c;
   }
 
   public Component getTreeCellRendererComponent(JTree tree, Object value,
                                  boolean selected, boolean expanded, boolean leaf,
                                  int row, boolean hasFocus)
   {
      if (selected) {
         setForeground(textSelectionColor);
         setBackground(backgroundSelectionColor);
         textarea.setForeground(textSelectionColor);
         textarea.setBackground(backgroundSelectionColor);
      } else {
         setForeground(textNonSelectionColor);
         setBackground(backgroundNonSelectionColor);
         textarea.setForeground(textNonSelectionColor);
         textarea.setBackground(backgroundNonSelectionColor);
      }
 
      textarea.setText(""+((DefaultMutableTreeNode) value).getUserObject()); 
      textarea.setCaretPosition(0);
 
      return this;
   }
}