Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Understanding the concept of passing objects through class constructors  RSS feed

 
Ross Gerard
Ranch Hand
Posts: 53
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abstract I want mjp1 and MJP2 to talk to each other and share objects. Not sure how.
Goal to enable jl1 when clicked to execture action listener on b2
























import java.awt.*;
import javax.swing.*;
import java.awt.event.*;




















 
Les Morgan
Rancher
Posts: 752
17
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ross,

You can easily do that by giving each of the objects a reference to each other, you can do this with the aid of the 3rd object:


Now MyClass2 and MyClass3 have references to each other, what you do from there is up to you.

BTW: you can do the same thing using constructors instead of setters.
 
Ross Gerard
Ranch Hand
Posts: 53
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was a great explanation I appreciate it. Now I can use that and study that then look up examples at Oracle. Thank you.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!