0

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

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by VernonDozier
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.