Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

This acts on inner Class

Tags:

java

I have a Class, which contains inner class. I want to send value, which equals to the top class, but "this" sends the value of inner class. What can I do?

package Controller;
public class MessageFrameListener{
private MessageFrame mf;
private User us;
private Contact cn;
private Timer timer;
private Running run;
private ListFrame lf;

public MessageFrameListener(ListFrame l_f, MessageFrame m_f, User u_s, Contact c_n, Running r_n){
    run = r_n;
    mf = m_f;
    us = u_s;
    cn = c_n;
    lf = l_f;
    m_f.addButtonListener(new SButtonListener());
    m_f.addWinListener(new FrameListener());

    timer = new Timer(500,new timerListener());
    timer.start();
}


public class FrameListener implements WindowListener{

    @Override
    public void windowClosing(WindowEvent e) {
        timer.stop();
        timer = null;
        mf.close();
        lf.removeMFL(this));
    }       
}
}

So, this line

        lf.removeMFL(this));

sends "FrameListener" by this, but I want to send "MessageFrameListener"

like image 596
146 percent Russian Avatar asked Dec 27 '22 00:12

146 percent Russian


2 Answers

Use the qualified this:

MessageFrameListener.this
like image 190
Malcolm Avatar answered Jan 08 '23 01:01

Malcolm


Use:

   lf.removeMFL(MessageFrameListener.this);
like image 37
Tony the Pony Avatar answered Jan 08 '23 01:01

Tony the Pony