hi i have a Jtree with usernames has nodes. how do i generate a code that when a user double clicks a username node, the corresponding code will execute along with what node was clicked on.
for example, a user clicks on username "jonney" and than a new chat window will appear to establish a chat session with jonney.
at the moment when a user selects a node, you are able to create a new chat session, but i want to change it so that the user has to double click their username not just selecting it. similar to msn mesenger.
here is the code i have at the moment.
public void valueChanged(TreeSelectionEvent event)
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode)
userTree.getLastSelectedPathComponent();
//get username.
Object nodeInfo = node.getUserObject();
String info =nodeInfo.toString();
if(node.isLeaf())
{
ChatDialog_c chatting = new ChatDialog_c(crnt_user, info);
Thread t = new Thread(chatting);
chatting.setTitle("I-comm");
chatting.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
chatting.setSize(430, 200);
chatting.getSize();
chatting.setLocation(420,200);
chatting.setVisible(true);
t.start();
}
}