WindowAdapter & this operator

V

vertigo

Hello
In Myclass (derived from Frame) i have:
class Myclass.....{
class WindowHandler extends WindowAdapter
{
public void windowActivated(WindowEvent e)
{
setFocus();
}
public void windowClosing(WindowEvent e)
{
AnotherObject.Close(XXX); /*here is problem*/
}
}
}

when i close Myclass i have to call other method from other class
with one parameter (which is reference to Myclass), but the problem is
that when i use this operator in WindowHandler class it return
WindowHandler class. How can i return reference to Myclass durring
windowClosing() ?

Thanx
Michal
 
C

Christophe Vanfleteren

vertigo said:
Hello
In Myclass (derived from Frame) i have:
class Myclass.....{
class WindowHandler extends WindowAdapter
{
public void windowActivated(WindowEvent e)
{
setFocus();
}
public void windowClosing(WindowEvent e)
{
AnotherObject.Close(XXX); /*here is problem*/
}
}
}

when i close Myclass i have to call other method from other class
with one parameter (which is reference to Myclass), but the problem is
that when i use this operator in WindowHandler class it return
WindowHandler class. How can i return reference to Myclass durring
windowClosing() ?

Thanx
Michal

You ha ve to use OuterClassName.this to get the "this reference":

So using:

AnotherObject.Close(MyClass.this);

should do the trick.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top