hi friend i am having problem with " this" refernce when it is passed as an agrument in any method . as everbody knows this alawys point to current live object , i am having few doubts about it . if any body has tutorial which explains is in details then plz provide me the link. a video would like icing on cake.here i am goin to post an j2me code plz help me to understand it
import javax.microedition.lcdui.*; public class demo extends MIDlet implements CommandListener { Form d1; TextField t1,t2; Command c1; Alert alert; public void startApp() { d1=new Form("Form1"); t1=new TextField("Enter Your Name","",10,TextField.ANY); t2=new TextField("","",20,TextField.ANY); Command c1=new Command("OK",Command.SCREEN,0); Command c2=new Command("Exit",Command.SCREEN,0); alert=new Alert("Field Empty","Text Field is empty",null,AlertType.ERROR); d1.append(t1); d1.append(t2); d1.addCommand(c1); d1.addCommand(c2); d1.setCommandListener(this); [COLOR="Red"][SIZE="3"] // i want to know about which object to "this" keyword is poiniting . is pointing to "d1"? is it possible to that "this" to/or can be made point to other object other than "d1" [/SIZE] [/COLOR] Display.getDisplay(this).setCurrent(d1); [COLOR="Red"][SIZE="3"]//is "this" here pointing to DISPLAY OBJECT or any other [/SIZE][/COLOR] } public void pauseApp() {} public void destroyApp(boolean unconditional) { notifyDestroyed(); } public void commandAction(Command c,Displayable d) { String lbl1=c.getLabel(); String lbl=t1.getString(); if(lbl.equals("")) { t2.setString("Field Empty"); } else { t2.setString("Hello "+lbl); } } }
thanks
anoop