Monday, March 28, 2011

Java Beans

JavaBeans are Java classes that have properties. You could think of properties as private instance variables. If they are private, the they can be accessed from outside of their class through methods in the class.

JavaBean Naming Rules for properties's members:
■ 'is' or 'get' for boolean values, example: boolean isOdd() or boolean getOdd(), boolean isError() or boolean getError();
■ get/set for other values

JavaBean Listener Naming Rules:
■ Listener method names which "register" a listener with an event source
must use the prefix add, followed by the listener type. For example,
addActionListener().
■ Listener method names which unregister a listener must use the prefix remove, followed by the listener type.
■ Listener method names must end with the word "Listener".

No comments:

Post a Comment