What are JavaBeans used for?

What for JavaBeans are used ?Can it be used for writinf a simle programme "HelloWorld"in java?It can be used for calculation?I am aware that they make the programming easier by components.But still not clear after reading OREILLI'S book.
[273 byte] By [maggiemaggiea] at [2007-11-26 19:13:08]
# 1
javabeans can be used to grow JavaTrees, or can be roasted, ground and sipped.
tjacobs01a at 2007-7-9 21:12:22 > top of Java-index,Desktop,Developing for the Desktop...
# 2
You can also feed 'em to trolls. But they might grow stronger then, which is an unwanted side effect.
J.Dannenberga at 2007-7-9 21:12:22 > top of Java-index,Desktop,Developing for the Desktop...
# 3
By giving such replies u r proving urself to be a loser.
maggiemaggiea at 2007-7-9 21:12:22 > top of Java-index,Desktop,Developing for the Desktop...
# 4

JavaBeans are Classes specifically designed to handle business logic. They act as the business tier in an N tier web application.

usually JSP's and servlets are used to handle the presentation and validation mechanisms, and JavaBeans have their properties set from within JSP or Servlets.

newtona at 2007-7-9 21:12:22 > top of Java-index,Desktop,Developing for the Desktop...
# 5

Hi MagieMagie.

Newton is absolutely correct. I just want to add a few more points.

1>A JavaBean is a reusable software component.. It is a Java class that defines properties and that communicates with other Beans via events. Properties can be defined within the JavaBean class definition, or they can be inherited from other classes. A Bean, however, is not required to inherit from any particular class or interface. Since it is a software component., one of its major benifits is reusability.

Another of its major benifits is its properties can be manipulated in a visual builder tool like NetBeans.

2> It can be simple, such as buttons, text fields, list boxes, scrollbars, and dialogs.

Or they may be more complex software components to handle business logics in JSP applications as newton has already mentioned.

Note that software components need not be visible in a running application; they only need to be visible in the builder tools when the application is constructed by a builder tool. A programmer can move, query, or visually hook together components while operating a builder tool. Often, such components do their work while the application is running, though they are invisible to the user.

JavaBeans that represent graphical components and that are meant to be visible must inherit from a java.awt.Component such as the java.awt.Canvas class, so that they can be added to visual containers.

3> Can it be used for writinf a simle programme "HelloWorld"in java?

Oh sure. Below is the code for a very simple bean. It's easy to understand.

import java.awt.*;

import java.io.Serializable;

public class SimpleBean extends Canvas

implements Serializable {

//Beans Property Declaration

private Color color = Color.green;

//getter method

public Color getColor() {

return color;

}

//setter method

public void setColor(Color newColor) {

color = newColor;

repaint();

}

//override paint method

public void paint (Graphics g) {

g.setColor(color);

g.fillRect(20,5,20,30);

}

//Constructor of the Bean: sets inherited properties

public SimpleBean() {

setSize(60,40);

setBackground(Color.red);

}

}

4> It can be used for calculation?

Definitely. That's what newton mentioned.

5>Very recently Sun has updated tutorials for java beans after a very long time. Just download the java tutorial (Novembor/10/2006) Edition from http://java.sun.com/docs/books/tutorial/information/download.html

U shall find it there. Its a really good one.

There are also several older tutorials on java beans at sun site which explains beautifully and are truely helpful. Below are three such links

http://java.sun.com/developer/onlineTraining/Beans/bean01/index.html >JavaBeans 101 Tutorial, Part I

http://java.sun.com/developer/onlineTraining/Beans/beans02/index.html>JavaBeans 101 Tutorial, Part II

http://java.sun.com/developer/onlineTraining/Beans/beans3/->JavaBeans 101 Tutorial, Part III

6>I'm also learning java beans at present all by myself and probably a very little ahead of u. If u r interested u may join me over the net. Together the learning may be a little easier. We can discuss our confusions.

If u r interested u can write me at cosmicdawn05@yahoo.co.in

Could I help? Bye.

PAUL

binaryFusiona at 2007-7-9 21:12:23 > top of Java-index,Desktop,Developing for the Desktop...
# 6
Read the JavaBeans specification, section 2: Fundamentals...
UncleSAMa at 2007-7-9 21:12:23 > top of Java-index,Desktop,Developing for the Desktop...
# 7
> Read the JavaBeans specification, section 2:> Fundamentals...Or use google....Or maybe come here to look for someone who wants to do your homework :)
Rabinoa at 2007-7-9 21:12:23 > top of Java-index,Desktop,Developing for the Desktop...
# 8
Thanks, your links are very useful.
zslevia at 2007-7-9 21:12:23 > top of Java-index,Desktop,Developing for the Desktop...