Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

bound property

 
Ranch Hand
Posts: 127
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
hi

as i understand bound properties

when property change something happend .by PropertyChangeSupport that use firePropertyChange to fire event

this method addPropertyChangeListener listen to event and

addPropertyChangeListener drive it where event will be handeled at propertyChange

is this correct and if it's correct why this code does give me this




import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyChangeEvent;
import java.io.*;
import javax.swing.JComponent;


public class testingbean extends JComponent implements Serializable{

private String title;
public testingbean() {
}

private final PropertyChangeSupport sss=new PropertyChangeSupport(this);

public void setTitle( String title )
{
String old = this.title;
this.title = title;
System.out.println("hello");
this.sss.firePropertyChange("Title", old, title );
}
public String getTitle( ){

return this.title;
}



public void addPropertyChangeListener( PropertyChangeListener listener )
{
System.out.println("hi");
this.sss.addPropertyChangeListener(new M());
}
public void removePropertyChangeListener( PropertyChangeListener listener )
{
this.sss.addPropertyChangeListener( listener );
}


public static void main(String arg[]){

testingbean x=new testingbean();


x.setTitle("Ahram");

x.setTitle("Akhbar");


}


class M implements PropertyChangeListener{


public void propertyChange(PropertyChangeEvent event)
{
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
System.out.println("sadasd");
System.out.println(newValue.toString());

}


}



}
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please don't post the same question twice. Closing this one.
 
    Bookmark Topic Watch Topic
  • New Topic