Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / October 2005

Tip: Looking for answers? Try searching our database.

Hi, I need your help! Jtree - JTextArea

Thread view: 
smat - 28 Oct 2005 14:40 GMT
his is my code, I need a JTextArea on JTree nodes. someone can help me?

import javax.swing.*;
import javax.swing.tree.*;
import java.awt.*;
import java.awt.event.*;
import java.util.EventObject;
import javax.swing.event.*;

public class Trees extends JFrame
{
JTree a;
DefaultMutableTreeNode node1;
DefaultMutableTreeNode node2;
DefaultMutableTreeNode node3;
JPanel p;

public Trees()
{
p=new JPanel();
node1 = new DefaultMutableTreeNode("node1");
node2 = new DefaultMutableTreeNode("node2");
a=new JTree(node1);
JTextAreaNodeRenderer j=new JTextAreaNodeRenderer();
a.setCellRenderer(j);
j.getTreeCellRendererComponent(a, null, true, true, true, 1, true);
node1.add(node2);
p.add(a);
a.setEditable(true);
setContentPane(p);
setVisible(true);
}

class JTextAreaNodeRenderer implements TreeCellRenderer
{
JTextArea ta;
public JTextArea getTreeCellRendererComponent(JTree tree, Object value,
boolean selected, boolean expanded, boolean leaf, int row, boolean
hasFocus)
{
ta = new JTextArea(5,20);
ta.setEditable(true);
return ta;
}
}

public static void main(String[]args)
{
Trees al = new Trees();
}
}
Andrew Thompson - 31 Oct 2005 04:56 GMT
> his is my code, I need a JTextArea on JTree nodes. someone can help me?

That depends on whether you can articulate the problem.

What is the problem?  What is the code supposed to do?
What is it doing instead?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.