File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes transfering an object variable from one class to another Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "transfering an object variable from one class to another" Watch "transfering an object variable from one class to another" New topic
Author

transfering an object variable from one class to another

Daniel Sie
Greenhorn

Joined: Aug 13, 2001
Posts: 7
I have created an object of a class A by using textboxes of a frame Af and save it to an ArrayList called AList.
I then created an object of a class B by using a textboxes of another frame Bf and save it to another ArrayList called BList.
There are 2 separate ArrayList because there are 2 different frames Af and Bf.
I also have created another frame Df that contains a TextArea.
How would I pass the objects that I have created to show in frame Df's TextArea using an ActionListener that is implemented on each Af and Bf?
I tried to do:
ActionListener listener = new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
Df.TextArea.append(//A's or B's methods);
}
};
But I got a compile error.
Can someone help me?
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
HI Daniel,
It would probably be helpful to explain what your compiler error is. One way to do it would be to create a frame Df then pass that into Af and Bf creations so that they can keep track of the Df frame. Then in each actionPerformed method you can call a method such as
localDf.showText( String s );
and have the actionPerformed method fill in s for the Df frame.
Regards,
Manfred.
Daniel Sie
Greenhorn

Joined: Aug 13, 2001
Posts: 7
Thanks I'll try that.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: transfering an object variable from one class to another
 
Similar Threads
controlling the return command
setAction and addActionListener
Hashmap
JTextField/Reading Content
Jxam TextArea scrollbars appear when necessary?