Hi
I have a main JFrame that calls a class(A) and that class calls another class (B)
In Class B I need a refrence to main JFrame
How to find that?
Thanks
Hi
I have a main JFrame that calls a class(A) and that class calls another class (B)
In Class B I need a refrence to main JFrame
How to find that?
Thanks
You can pass a reference of the JFrame to the classes like so
public class SomeFrame extends JFrame {
.
.
.
ClassA classA = new ClassA(arg1, arg2..., this, ...);
.
.
.
In ClassA:
public class ClassA {
private JFrame someFrame;
public ClassA(arg1, arg2... JFrame someFrame,...)
{
this.someFrame = someFrame;
.
.
.
ClassB classB = new ClassB(arg1, arg2, this.someFrame, ...);
.
.
.
In ClassB:
public class ClassB {
private JFrame someFrame;
public ClassB(arg1, arg2, JFrame someFrame, ...) {
this.someFrame = someFrame;
.
.
.