java - Change private variable value inside interface implementation -
i'm having trouble changing value of private variable ( of class implements interface) inside interface implementation.
i have interface iclient:
public interface iclient{ void shownewarticles(article a); } and class client implements iclient:
public class client implements iclient{ ( .... ) private defaultlistmodel<string> listmodelarticles = new defaultlistmodel<>(); ( .... ) @override public void shownewarticles(article a){ string infoarticle = ("["+a.getkeyword().touppercase()+"] "+a.gettitle()); listmodelarticles.addelement(infoarticle); listarticles.setmodel(listmodelarticles); } } the problem when execute shownewarticles() method, doesn't add element in listmodelarticles, if create private or public method (inside client class ) , execute listmodelarticles.addelement(infoarticles) inside it, infoarticle inserted model correctly. access modifiers?
i found solution. problem class call the iclient method of client class. tried solve problem :)
my solution:
@override public void shownewarticles(article a) throws remoteexception { iclient client = maincontroller.getinstance().getclient(); client.shownewarticles(a); } before solution:
@override public void shownewarticles(article a) throws remoteexception { clienti.getinstance().shownewarticles(a); } i don't know why wasn't working before, though using singleton. works.
Comments
Post a Comment