I have 2 classes Engine.java and Window.java . In the Window.java I have a button which will create instance of the Engine.java.
How can I pass Window.java to Engine.java?
I know that I can use this, but this represent button at that moment of clicking button.
The reason is that I want to have access to all component of Window.java within Engine.java.
public class Engine{
Window window;
public Engine(Window en){
window = en;
}
//rest of your code
}
public class Window(){
btnDownload.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
//At the point where you create the Engine
Engine en = new Engine(this);
//rest of your code
}
}
this should work…