As you have discovered there is more than one way to solve the problem:
Pass a reference in:
the constructor where it is saved for later use
the method call where it is used
Type: Posts; User: Norm
As you have discovered there is more than one way to solve the problem:
Pass a reference in:
the constructor where it is saved for later use
the method call where it is used
See post #6 for a short piece of code that passes a reference to a constructor and has the constructor save the reference in a class variable.
That's another way to do it.
Use the reference to the MainWindow object that is passed to the constructor.
m.setYazi("Suitable. Count: "+sayac+");
In the above, m should be the reference that was passed to the Hail class....
Where is there a reference to the existing instance of the MainWindow class? If the code in the MainWindow class is calling the constructor, use the this variable. this refers to the class where the...
You need to make a reference to the existing, visible window available to the code that wants to use it.
One way would be to pass the reference in the call to the Hail class's constructor and have...
How many MainWindow objects are created by the program? Add a println statement in the constructor that prints a message so you will know.
How many should it create?
What if one is visible and...