Click here to Skip to main content
15,886,772 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In java how would I select and fire event(or events)on a node of the tree object in desktop application...?

What I have tried:

I have created the JTree object and placed some child node in it. But now i dont know how would I select a particular child node and fir the appropriate event on it. Please he
Posted
Updated 3-Jun-22 2:18am

 
Share this answer
 
Comments
Member 12712527 9-Jun-22 21:48pm    
This program is file when there is only one window. but when there is two window it doesn't work out.
how...?
First of all I have defined two classes which decorates the window.
Secondly I have added these two classes to a splitterpane and added that splitterpane to another frame(main window).
Now in the first class i have defined a JTree object...
second window is left out.
Problem arises when i clicked one of the child node....
the base node is "family"
And two other child nodes are "father" and "mother"
Both in father and mother there is one child node named "create child"
Now when i clicked the create child node a new form is displayed asking for the name of the child node.
when i gave the name and clicked the okay button, it returns to main window by calling the main window's contructor.
Now in the constructor of the first class I have mentioned a static variable "pCreateRep" with a value of zero
Now when the " create child " node is clicked,
another form is displayed and the value of pCreateRep changes to one.
this value is returned to the first class and the decorated form's addObject is called...
I know that the value of the first form's components will be lost if another window opens.
for that i've made each component in the first class as static....
but still the addObject method doesn't work.... please help...
Richard MacCutchan 10-Jun-22 3:16am    
It sounds like your design needs to be reworked. You should not need static classes to mange Window events.
Member 12712527 10-Jun-22 7:43am    
I'm not using static classes but other variables are declared static. Sir without static how would i be able to retain the value of a variable...?
Richard MacCutchan 10-Jun-22 8:05am    
All variables in your class objects retain their values. Using static variables is rarely necessary, and in some case will actually cause problems. As I said, you need to look at your design.
Member 12712527 10-Jun-22 7:45am    
Sir same code if done on a single window, works but if done on more than one window fails
Your question makes no sense.

You do not "select and fire events". Objects raise events themselves based on their condition and what is happening to them. Events are the objects way of notifying your code that something interesting happened to it.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900