Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

transfering an object variable from one class to another

 
Daniel Sie
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks I'll try that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic