i have a code with me
import java.applet.*;
import java.awt.*;
/*<applet code="DialogTester" width=400 height=400></applet>*/
public class DialogTester extends Applet
{
public void init()
{
Container container=this.getParent();//this ;why not create object of the class and call the function
while(!(container instanceof Frame))
{
container=container.getParent();
}
Frame parent=(Frame)container;
Dialog myDialog=new Dialog(parent,false);
myDialog.setLocation(320,240);
myDialog.add(new Label("hello"));
myDialog.add(new Button("ok"),BorderLayout.SOUTH);
myDialog.pack();
myDialog.show();
}
}
can somebody tell me the perfect concept of "this".I have encountered it several times."this" points to the class and is an instance of class.I know "this" is used to avoid name collision.Can somebody ellaborate and enlighten me. thanks