Why change to same variable in one anonymous class is not visible in another anonym class in java? -
i have interesting issue should explain.
my code simple:
public class savefilechooser extends basefilechooser { private string selectedfilepath = null; public savefilechooser(string title) { super(title); super.addpropertychangelistener(file_filter_changed_property, new propertychangelistener() { @override public void propertychange(propertychangeevent evt) { system.out.println(" selectedfilepath=" + selectedfilepath); } }); super.addpropertychangelistener(selected_file_changed_property, new propertychangelistener() { @override public void propertychange(propertychangeevent evt) { selectedfilepath = string.valueof(evt.getnewvalue()); system.out.println("selectedfilepath=" + selectedfilepath); } }); } } as see selectedfilepath variable assigned value in below listener selected_file_changed_property property.
and in above listener value of var read. see on console @ first assign new non-null value in bottom listener , read in above listener.
unfortunately selectedfilepath in above listener null. why that?
Comments
Post a Comment