File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Referencing same instance from multiple separate classes. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Referencing same instance from multiple separate classes." Watch "Referencing same instance from multiple separate classes." New topic

Referencing same instance from multiple separate classes.

Joe Poyner

Joined: Mar 05, 2008
Posts: 1
Not sure if I am wording this question correctly, but I will give it a shot. BTW, thanks alot for anyones time and help with this question.

So I have a program with 3 classes I have made, what each of them has is listed below each subtitle.

Main class - contains new UI object.

Contains several static classes that analyze modify data based on the inputs and outputs given.

The entire UI interface.

So, here is the question, I create a new UI instance in main. What I need to do is access the getter and setter methods within the UI instance I created from inside Manipulator. Im not exactly sure how to accomplish it. So the options that I thought of were the following, put UI and Manipulator in the same class so that they have access to one another, or use methods in main to pull the desired var's in and then place them. Honestly I would rather just have the instance of UI I create be accessible to Manipulator.

For now I wont post the code because it is getting long and involved but if need be I can.

Thanks again!
[ March 10, 2008: Message edited by: Joe Poyner ]
marc weber

Joined: Aug 31, 2004
Posts: 11343

Welcome to JavaRanch!

It sounds like you're using the Model View Controller (MVC) pattern. That's good. See if these examples help you put it together...

MVC - Multiply.

MVC - Temperature.

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
I agree. Here's the link:
subject: Referencing same instance from multiple separate classes.
It's not a secret anymore!