WindowAdapter & this operator

Discussion in 'Java' started by vertigo, Apr 9, 2004.

  1. vertigo

    vertigo Guest

    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
     
    vertigo, Apr 9, 2004
    #1
    1. Advertising

  2. vertigo wrote:

    > 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.

    --
    Kind regards,
    Christophe Vanfleteren
     
    Christophe Vanfleteren, Apr 9, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jakob Bieling

    Q: operator void* or operator bool?

    Jakob Bieling, Mar 5, 2004, in forum: C++
    Replies:
    2
    Views:
    589
    Rob Williscroft
    Mar 5, 2004
  2. John Smith
    Replies:
    2
    Views:
    427
    Ivan Vecerina
    Oct 6, 2004
  3. Alex Vinokur
    Replies:
    4
    Views:
    3,056
    Peter Koch Larsen
    Nov 26, 2004
  4. Alex Vinokur
    Replies:
    3
    Views:
    5,033
    Jeff Schwab
    Mar 20, 2005
  5. Tim Clacy
    Replies:
    15
    Views:
    2,692
    Kanenas
    May 30, 2005
Loading...

Share This Page