File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help with Class interactions" Watch "Help with Class interactions" New topic

Help with Class interactions

Michael Eller
Ranch Hand

Joined: Feb 28, 2004
Posts: 32
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 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,
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:
I agree. Here's the link:
subject: Help with Class interactions
It's not a secret anymore!