Question

What exactly are Java Beans?

Answer

Java Beans are components that can be used to assemble a larger Java application. Beans are classes that have properties, and can trigger events.

To define a property, a bean author provides accessor methods, that can get and set the value of a property. A bean tool should inspect the class for methods matching the get/set pattern, and allow you to modify the object's properties.

public class MyFirstBean
{
	private String name;

	public MyFirstBean()
	{
		name = new String("MyFirstBean");
	}

	public String getName()
	{
		return name;
	}

	public void setName( String newName )
	{
		name = newName;
	}

}

This is a very simple bean, within minimal functionality. It triggers no events, and has a single property, but does introduce you to the basics of beans. For more information on beans, check out the following resources :


Back