Launch your tech mastery with us—your coding journey starts now!
Course Content
Advanced Java

A JavaBean is reusable, platform independent component that can be manipulated visually in a builder tool.

In computing, based on the Java Platform, JavaBeans are classes that encapsulate many objects into a single object (the bean). In simple words JavaBean is nothing but a Java class. When these JavaBeans are used in other applications, the internal working of such components are hidden from the application developer.

Example:

All Swing and AWT classes are JavaBeans. GUI components are ideal JavaBeans.

Components of JavaBeans

The classes that contained definition of beans is known as components of JavaBeans. These classes follows certain design conventions. It includes properties, events, methods and persistence. There are two types of components, GUI based and non GUI based. For instance JButton is example of a component not a class.

Properties (date members): Property is a named attribute of a bean, it includes color, label, font, font size, display size. It determines appearance, behavior and state of a bean.

Methods: Methods in JavaBeans are same as normal Java methods in a class. It doesn’t follow any specific naming conventions. All properties should have accessor and getter methods.

Events: Events in JavaBeans are same as SWING/AWT event handling.

Persistence: Serializable interface enables JavaBean to store its state.

JavaBean has no argument constructor.

    JavaBean component