java - Using Interface in a Class for Function -



java - Using Interface in a Class for Function -

this programme totally working way want be. there 1 line can't understand bottom of frompanel. learned tutorial video.

this interface

public interface stringlistener { public void emittext(string text); }

this formpanel class

public class formpanel extends jpanel { stringlistener txtlistener; private string name; private string age; private string address; private jtextfield namef; private jtextfield agef; private jtextfield addressf; private jbutton ok; public formpanel() { namef = new jtextfield(8); agef = new jtextfield(8); addressf = new jtextfield(8); ok = new jbutton("ok"); setlayout(new gridbaglayout()); ok.addactionlistener(new actionlistener() { public void actionperformed(actionevent arg0) { name = namef.gettext().tostring(); age = agef.gettext().tostring(); address = addressf.gettext().tostring(); txtlistener.emittext("\n hello! " + name + "\n"); txtlistener.emittext("you " + age + " years old \n"); txtlistener.emittext("you lived in " + address); } }); } public void showinfo(stringlistener listener) { this.txtlistener = listener; /// cant understand line } }

the line simple sets txtlisterner given stringlistener. migth confused because you've written listener capital l.

java eclipse swing

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -