This question already has an answer here:
- What is a JavaBean exactly? 14 answers
The name really throws me off. I'm hoping someone can explain it in a way I won't forget :)
This question already has an answer here:
The name really throws me off. I'm hoping someone can explain it in a way I won't forget :)
Any serializable java class (implementing java.io.Serializable) that follows specific conventions: a no-argument constructor, and properties accessible via get/set/is accessors.
The idea is to make it predictable, so that properties etc can be discovered automatically through reflection - of great help in tool and framework development.
http://en.wikipedia.org/wiki/JavaBean
JavaBeans are reusable software components for Java that can be manipulated visually in a builder tool. Practically, they are classes written in the Java programming language conforming to a particular convention. They are used to encapsulate many objects into a single object (the bean), so that they can be passed around as a single bean object instead of as multiple individual objects. A JavaBean is a Java Object that is serializable, has a nullary constructor, and allows access to properties using getter and setter methods.
continue reading »
alt text http://www.javalobby.org/articles/j2me-in-a-nutshell/CoffeeBeanSingle.jpg
Sun's JavaBean Tutorial says...
The JavaBeans™ architecture is based on a component model which enables developers to >create software units called components. Components are self-contained, reusable software units that can be visually assembled into composite components, applets, applications, and servlets using visual application builder tools. JavaBean components are known as beans.
A set of APIs describes a component model for a particular language. The JavaBeans API specificationdescribes the core detailed elaboration for the JavaBeans component architecture.
Beans are dynamic in that they can be changed or customized. Through the design mode of a builder tool you can use the Properties window of the bean to customize the bean and then save (persist) your beans using visual manipulation. You can select a bean from the toolbox, drop it into a form, modify its appearance and behavior, define its interaction with other beans, and combine it and other beans into an applet, application, or a new bean.
If you've used Swing's 'button', then you've used a component (visible JavaBean). You can use developers tools (like NetbeansIDE) to change the Bean's available 'properties'. Netbeans uses something called 'introspection' to discover which JavaBean properties can be modified by the coder/user (e.g. name, text-title and alignment for a Swing Button JavaBean component). You can save its state too (the IDE/Beans developer might use 'serialization' to do this) allowing re-use with your favourite settings another time.
JavaBeans don't need to be visible (like a swing component). You could create your own JavaBean to encrypt text in a textbox when someone clicks an 'OK' button on a form. You don't see your custom written JavaBean, but some other developer could re-use your 'encryption' JavaBean in their code with some 'property' changes that you allowed to be public (i.e. encryption-type="blowfish").
Regards, SteJav
JavaBeans are reusable software component written in java.The components can be configured and connected using builder tools.Three key properties that causes any class in java to become a javabean is
1.Class is serializable
2.class has a 0 argument constructor
3.class has getter and setter methods for data members
Here is a simple class that is eligible for becoming a javabean
import java.io.*;
public class Student implements Serializable {
private String name = null;
//0 argument constructor
public Student() {
}
//getter method
public String getName() {
return name;
}
//settor method
public void setName(final String name) {
this.name = value;
}
}
A java bean is a class that is serializable, has a no-argument constructor, and uses getters and setter methods for its member fields. Its used in Java Enterprise Apps to store business logic data.
A JavaBean is a Java object that satisfies below programming conventions: