aspose file tools*
The moose likes Java in General and the fly likes Help with Class interactions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help with Class interactions" Watch "Help with Class interactions" New topic
Author

Help with Class interactions

Michael Eller
Ranch Hand

Joined: Feb 28, 2004
Posts: 32
Hello,
I am just getting back into this and have a question that is giving me a problem.
I have a class that implements the JFrame (this class also contains the main function).
I have another class that provides the menubar, menus, etc to the class with the JFrame.
Everything works fine until I try to add an action listener to a menu item that will change something in the JFrame.....the two classes will not talk. I cannot use the
"class" <variable> = new "class" which would call the constructor....to implement this in this way would call the constructor for the JFrame class....and this is no good.
How can I access objects between classes without calling the constructor?
Any assistance is greatly appreciated,
Mike
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

You may create the menu from the Frame.
To make the menu able to modify things belonging to the frame, the menu needs a reference to the frame.
So the frame should hand this reference to the menu:
(Pseudocode


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with Class interactions