object is passed as an argument not declared
<p>The problem with this code is that whenever i run this it shows the compilation error:</p>

<blockquote>
  <p>cannot find symbol:constructor mywindowadapter(frame1)</p>
  
  <p>location:class mywindowadapter</p>
  
  <p>mywindowadapter mwa=new mywindowadapter()"    </p>
</blockquote>

<pre><code>import java.awt.*;
import java.awt.event.*;
/*&lt;applet code=frame2 width=500 height=500&gt;
&lt;/applet&gt;*/
class frame2 extends Frame
{
    frame2(String title)
    {
        super(title);
        mywindowadapter mwa=new mywindowadapter();
        addWindowListener(mwa);     
    }
    public static void main(String ar[])
    {
        frame2 f=new frame2("my frame");
        f.setVisible(true);
        f.setSize(200,100);

     }
    public void paint(Graphics g)
    {
        g.drawString("hello frame",60,70);
    }
}
class mywindowadapter extends WindowAdapter
{

    mywindowadapter()
    {
        frame2 f=new frame2();  
    }
    public void windowClosing(WindowEvent we)
    {
        f.setVisible(false);
        System.exit(0);
    }
} 
</code></pre>

<p>The code below is the rectified version of the above code. i am not able to understand the error generated in the previous code. please help!!</p>

<pre><code>import java.awt.*;
import java.awt.event.*;
/*&lt;applet code=frame2 width=500 height=500&gt;
&lt;/applet&gt;*/
class frame2 extends Frame
 {
    frame2(String title)
    {
        super(title);
        mywindowadapter mwa=new mywindowadapter(this);
        addWindowListener(mwa);     
    }
    public static void main(String ar[])
    {
        frame2 f=new frame2("my frame");
        f.setVisible(true);
        f.setSize(200,100);

    }
   public void paint(Graphics g)
    {
        g.drawString("hello frame",60,70);
    }
}
class mywindowadapter extends WindowAdapter
{
    frame2 f;
    mywindowadapter(frame2 f)
    {
        this.f=f;   
    }
    public void windowClosing(WindowEvent we)
    {
        f.setVisible(false);
        System.exit(0);
    }
}   
</code></pre>
