Java Doc for AbstractBean.java in  » Swing-Library » swingx » org » jdesktop » beans » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » swingx » org.jdesktop.beans 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.jdesktop.beans.AbstractBean

All known Subclasses:   org.jdesktop.swingx.painter.ImageEffect,  org.jdesktop.swingx.painter.AbstractPainter,  org.jdesktop.swingx.auth.LoginService,  org.jdesktop.swingx.auth.UserNameStore,
AbstractBean
abstract public class AbstractBean (Code)

A convenience class from which to extend all non-visual JavaBeans. It manages the PropertyChange notification system, making it relatively trivial to add support for property change events in getters/setters.

A non-visual java bean is a Java class that conforms to the JavaBean patterns to allow visual manipulation of the bean's properties and event handlers at design-time.

Here is a simple example bean that contains one property, foo, and the proper pattern for implementing property change notification:


 public class ABean extends JavaBean {
 private String foo;
 public void setFoo(String newFoo) {
 String old = getFoo();
 this.foo = newFoo;
 firePropertyChange("foo", old, getFoo());
 }
 public String getFoo() {
 return foo;
 }
 }
 

You will notice that "getFoo()" is used in the setFoo method rather than accessing "foo" directly for the gets. This is done intentionally so that if a subclass overrides getFoo() to return, for instance, a constant value the property change notification system will continue to work properly.

The firePropertyChange method takes into account the old value and the new value. Only if the two differ will it fire a property change event. So you can be assured from the above code fragment that a property change event will only occur if old is indeed different from getFoo()

JavaBean also supports VetoablePropertyChange events. These events are similar to PropertyChange events, except a special exception can be used to veto changing the property. For example, perhaps the property is changing from "fred" to "red", but a listener deems that "red" is unexceptable. In this case, the listener can fire a veto exception and the property must remain "fred". For example:


 public class ABean extends JavaBean {
 private String foo;
 public void setFoo(String newFoo) throws PropertyVetoException {
 String old = getFoo();
 this.foo = newFoo;
 fireVetoableChange("foo", old, getFoo());
 }
 public String getFoo() {
 return foo;
 }
 }
 public class Tester {
 public static void main(String... args) {
 try {
 ABean a = new ABean();
 a.setFoo("fred");
 a.addVetoableChangeListener(new VetoableChangeListener() {
 public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
 if ("red".equals(evt.getNewValue()) {
 throw new PropertyVetoException("Cannot be red!", evt);
 }
 }
 }
 a.setFoo("red");
 } catch (Exception e) {
 e.printStackTrace(); // this will be executed
 }
 }
 }
 


author:
   rbair



Constructor Summary
protected  AbstractBean()
    
protected  AbstractBean(PropertyChangeSupport pcs, VetoableChangeSupport vcs)
     Creates a new instance of JavaBean, using the supplied PropertyChangeSupport and VetoableChangeSupport delegates.

Method Summary
final public  voidaddPropertyChangeListener(PropertyChangeListener listener)
     Add a PropertyChangeListener to the listener list.
final public  voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener)
     Add a PropertyChangeListener for a specific property.
final public  voidaddVetoableChangeListener(VetoableChangeListener listener)
     Add a VetoableListener to the listener list.
final public  voidaddVetoableChangeListener(String propertyName, VetoableChangeListener listener)
     Add a VetoableChangeListener for a specific property.
public  Objectclone()
    
final protected  voidfireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue)
     Report a bound indexed property update to any registered listeners.
final protected  voidfirePropertyChange(String propertyName, Object oldValue, Object newValue)
     Report a bound property update to any registered listeners.
final protected  voidfirePropertyChange(PropertyChangeEvent evt)
     Fire an existing PropertyChangeEvent to any registered listeners.
final protected  voidfireVetoableChange(String propertyName, Object oldValue, Object newValue)
     Report a vetoable property update to any registered listeners.
final protected  voidfireVetoableChange(PropertyChangeEvent evt)
     Fire a vetoable property update to any registered listeners.
final public  PropertyChangeListener[]getPropertyChangeListeners()
     Returns an array of all the listeners that were added to the PropertyChangeSupport object with addPropertyChangeListener().

If some listeners have been added with a named property, then the returned array will be a mixture of PropertyChangeListeners and PropertyChangeListenerProxys.

final public  PropertyChangeListener[]getPropertyChangeListeners(String propertyName)
     Returns an array of all the listeners which have been associated with the named property.
Parameters:
  propertyName - The name of the property being listened to all of the PropertyChangeListeners associated withthe named property.
final public  VetoableChangeListener[]getVetoableChangeListeners()
     Returns the list of VetoableChangeListeners.
final public  VetoableChangeListener[]getVetoableChangeListeners(String propertyName)
     Returns an array of all the listeners which have been associated with the named property.
Parameters:
  propertyName - The name of the property being listened to all the VetoableChangeListeners associated withthe named property.
final protected  booleanhasPropertyChangeListeners(String propertyName)
     Check if there are any listeners for a specific property, including those registered on all properties.
final protected  booleanhasVetoableChangeListeners(String propertyName)
     Check if there are any listeners for a specific property, including those registered on all properties.
final public  voidremovePropertyChangeListener(PropertyChangeListener listener)
     Remove a PropertyChangeListener from the listener list.
final public  voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener)
     Remove a PropertyChangeListener for a specific property.
final public  voidremoveVetoableChangeListener(VetoableChangeListener listener)
     Remove a VetoableChangeListener from the listener list.
final public  voidremoveVetoableChangeListener(String propertyName, VetoableChangeListener listener)
     Remove a VetoableChangeListener for a specific property.


Constructor Detail
AbstractBean
protected AbstractBean()(Code)
Creates a new instance of JavaBean



AbstractBean
protected AbstractBean(PropertyChangeSupport pcs, VetoableChangeSupport vcs)(Code)
Creates a new instance of JavaBean, using the supplied PropertyChangeSupport and VetoableChangeSupport delegates. Neither of these may be null.




Method Detail
addPropertyChangeListener
final public void addPropertyChangeListener(PropertyChangeListener listener)(Code)
Add a PropertyChangeListener to the listener list. The listener is registered for all properties. The same listener object may be added more than once, and will be called as many times as it is added. If listener is null, no exception is thrown and no action is taken.
Parameters:
  listener - The PropertyChangeListener to be added



addPropertyChangeListener
final public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)(Code)
Add a PropertyChangeListener for a specific property. The listener will be invoked only when a call on firePropertyChange names that specific property. The same listener object may be added more than once. For each property, the listener will be invoked the number of times it was added for that property. If propertyName or listener is null, no exception is thrown and no action is taken.
Parameters:
  propertyName - The name of the property to listen on.
Parameters:
  listener - The PropertyChangeListener to be added



addVetoableChangeListener
final public void addVetoableChangeListener(VetoableChangeListener listener)(Code)
Add a VetoableListener to the listener list. The listener is registered for all properties. The same listener object may be added more than once, and will be called as many times as it is added. If listener is null, no exception is thrown and no action is taken.
Parameters:
  listener - The VetoableChangeListener to be added



addVetoableChangeListener
final public void addVetoableChangeListener(String propertyName, VetoableChangeListener listener)(Code)
Add a VetoableChangeListener for a specific property. The listener will be invoked only when a call on fireVetoableChange names that specific property. The same listener object may be added more than once. For each property, the listener will be invoked the number of times it was added for that property. If propertyName or listener is null, no exception is thrown and no action is taken.
Parameters:
  propertyName - The name of the property to listen on.
Parameters:
  listener - The VetoableChangeListener to be added



clone
public Object clone() throws CloneNotSupportedException(Code)



fireIndexedPropertyChange
final protected void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue)(Code)
Report a bound indexed property update to any registered listeners.

No event is fired if old and new values are equal and non-null.

This is merely a convenience wrapper around the more general firePropertyChange method that takes PropertyChangeEvent value.
Parameters:
  propertyName - The programmatic name of the property thatwas changed.
Parameters:
  index - index of the property element that was changed.
Parameters:
  oldValue - The old value of the property.
Parameters:
  newValue - The new value of the property.




firePropertyChange
final protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)(Code)
Report a bound property update to any registered listeners. No event is fired if old and new are equal and non-null.

This is merely a convenience wrapper around the more general firePropertyChange method that takes PropertyChangeEvent value.
Parameters:
  propertyName - The programmatic name of the propertythat was changed.
Parameters:
  oldValue - The old value of the property.
Parameters:
  newValue - The new value of the property.




firePropertyChange
final protected void firePropertyChange(PropertyChangeEvent evt)(Code)
Fire an existing PropertyChangeEvent to any registered listeners. No event is fired if the given event's old and new values are equal and non-null.
Parameters:
  evt - The PropertyChangeEvent object.



fireVetoableChange
final protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws PropertyVetoException(Code)
Report a vetoable property update to any registered listeners. If anyone vetos the change, then fire a new event reverting everyone to the old value and then rethrow the PropertyVetoException.

No event is fired if old and new are equal and non-null.
Parameters:
  propertyName - The programmatic name of the propertythat is about to change..
Parameters:
  oldValue - The old value of the property.
Parameters:
  newValue - The new value of the property.
exception:
  PropertyVetoException - if the recipient wishes the propertychange to be rolled back.




fireVetoableChange
final protected void fireVetoableChange(PropertyChangeEvent evt) throws PropertyVetoException(Code)
Fire a vetoable property update to any registered listeners. If anyone vetos the change, then fire a new event reverting everyone to the old value and then rethrow the PropertyVetoException.

No event is fired if old and new are equal and non-null.
Parameters:
  evt - The PropertyChangeEvent to be fired.
exception:
  PropertyVetoException - if the recipient wishes the propertychange to be rolled back.




getPropertyChangeListeners
final public PropertyChangeListener[] getPropertyChangeListeners()(Code)
Returns an array of all the listeners that were added to the PropertyChangeSupport object with addPropertyChangeListener().

If some listeners have been added with a named property, then the returned array will be a mixture of PropertyChangeListeners and PropertyChangeListenerProxys. If the calling method is interested in distinguishing the listeners then it must test each element to see if it's a PropertyChangeListenerProxy, perform the cast, and examine the parameter.

 PropertyChangeListener[] listeners = bean.getPropertyChangeListeners();
 for (int i = 0; i < listeners.length; i++) {
 if (listeners[i] instanceof PropertyChangeListenerProxy) {
 PropertyChangeListenerProxy proxy = 
 (PropertyChangeListenerProxy)listeners[i];
 if (proxy.getPropertyName().equals("foo")) {
 // proxy is a PropertyChangeListener which was associated
 // with the property named "foo"
 }
 }
 }
 

See Also:   java.beans.PropertyChangeListenerProxy all of the PropertyChangeListeners added or an empty array if no listeners have been added



getPropertyChangeListeners
final public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)(Code)
Returns an array of all the listeners which have been associated with the named property.
Parameters:
  propertyName - The name of the property being listened to all of the PropertyChangeListeners associated withthe named property. If no such listeners have been added,or if propertyName is null, an empty array isreturned.



getVetoableChangeListeners
final public VetoableChangeListener[] getVetoableChangeListeners()(Code)
Returns the list of VetoableChangeListeners. If named vetoable change listeners were added, then VetoableChangeListenerProxy wrappers will returned

List of VetoableChangeListeners and VetoableChangeListenerProxysif named property change listeners were added.




getVetoableChangeListeners
final public VetoableChangeListener[] getVetoableChangeListeners(String propertyName)(Code)
Returns an array of all the listeners which have been associated with the named property.
Parameters:
  propertyName - The name of the property being listened to all the VetoableChangeListeners associated withthe named property. If no such listeners have been added,or if propertyName is null, an empty array isreturned.



hasPropertyChangeListeners
final protected boolean hasPropertyChangeListeners(String propertyName)(Code)
Check if there are any listeners for a specific property, including those registered on all properties. If propertyName is null, only check for listeners registered on all properties.
Parameters:
  propertyName - the property name. true if there are one or more listeners for the given property



hasVetoableChangeListeners
final protected boolean hasVetoableChangeListeners(String propertyName)(Code)
Check if there are any listeners for a specific property, including those registered on all properties. If propertyName is null, only check for listeners registered on all properties.
Parameters:
  propertyName - the property name. true if there are one or more listeners for the given property



removePropertyChangeListener
final public void removePropertyChangeListener(PropertyChangeListener listener)(Code)
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties. If listener was added more than once to the same event source, it will be notified one less time after being removed. If listener is null, or was never added, no exception is thrown and no action is taken.
Parameters:
  listener - The PropertyChangeListener to be removed



removePropertyChangeListener
final public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)(Code)
Remove a PropertyChangeListener for a specific property. If listener was added more than once to the same event source for the specified property, it will be notified one less time after being removed. If propertyName is null, no exception is thrown and no action is taken. If listener is null, or was never added for the specified property, no exception is thrown and no action is taken.
Parameters:
  propertyName - The name of the property that was listened on.
Parameters:
  listener - The PropertyChangeListener to be removed



removeVetoableChangeListener
final public void removeVetoableChangeListener(VetoableChangeListener listener)(Code)
Remove a VetoableChangeListener from the listener list. This removes a VetoableChangeListener that was registered for all properties. If listener was added more than once to the same event source, it will be notified one less time after being removed. If listener is null, or was never added, no exception is thrown and no action is taken.
Parameters:
  listener - The VetoableChangeListener to be removed



removeVetoableChangeListener
final public void removeVetoableChangeListener(String propertyName, VetoableChangeListener listener)(Code)
Remove a VetoableChangeListener for a specific property. If listener was added more than once to the same event source for the specified property, it will be notified one less time after being removed. If propertyName is null, no exception is thrown and no action is taken. If listener is null, or was never added for the specified property, no exception is thrown and no action is taken.
Parameters:
  propertyName - The name of the property that was listened on.
Parameters:
  listener - The VetoableChangeListener to be removed



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.