Results 1 to 5 of 5

Thread: Concept of java beans

  1. #1
    Join Date
    Jan 2009
    Posts
    45

    Concept of java beans

    Hi All,

    I am beginner in the java programmer. I am getting difficulties in understanding the concept of the "Java beans". Java beans concept is very complicated. I have gone through different java book but id doesn't works.

    I need your help to understand the "Java beans" concept. I will appreciate you help if are able to explain it with suitable example.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Concept of java beans

    Hi,

    The classes of the java programming which follows the particular conventions of coding is referred as "Java beans".

    Following are the some example of the conventions of coding:

    1. Providing constructor with no argument

    2. Providing setter & getter methods to take access over it's properties

    3.Implementing interface "java.io.Serializable"accessing it's properties

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: Concept of java beans

    Please study below program of the "Java beans" careful. Which will demonstrate you how to use java beans.
    Copy the below code and execute on your computer:

    package com.stardeveloper.bean.test;

    public class BeanDemo implements java.io.Serializable {



    private String nm = null; // Properties
    private int age1 = 0;


    public BeanDemo() {}


    public String getName() {
    return nm;
    }

    public void setName(String s) {
    nm = s;
    }

    public int getAge() {
    return age1;
    }

    public void setAge1(int a) {
    age1 =a;
    }
    }

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    Re: Concept of java beans

    Reusable component of the software which is manipulated visually within builder tools is known as " Java Bean".

    Following are the some well-known features of the Java Beans:

    1. Java Beans has support over "customization" which enable user to change the behavior as well as appearance.

    2. Java Beans has support to "Introspection " which enable builder tool for analyzing working of the beans.

    3. Java Beans has support to "event" which enables a user to fire different events.

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    Re: Concept of java beans

    Below is the simple bean program, which changes the Background color to "GREEN ",foreground color to "BLUE ". and also changes the alignment.
    Below java bean program code is running successfully on my machine:


    import javax.swing.JLabel;
    import java.awt.Color;
    import java.io.Serializable;
    import java.beans.XMLDecoder;


    public class BeanDM extends JLabel
    implements Serializable {

    public BeanDM() {

    setText( "Hi all!" );

    setOpaque( true );

    setBackground( Color.GREEN );

    setForeground( Color.BLUE );

    setVerticalAlignment( RIGHT );

    setHorizontalAlignment( RIGHT );

    }
    }

Similar Threads

  1. Why we use Introspection in Java Beans?
    By taher in forum Software Development
    Replies: 4
    Last Post: 17-02-2010, 06:23 AM
  2. Java Beans Vs Servlets
    By Ram Bharose in forum Software Development
    Replies: 5
    Last Post: 02-02-2010, 11:53 AM
  3. What are the advantages of the java beans?
    By Bhavesh_seth in forum Software Development
    Replies: 3
    Last Post: 04-12-2009, 11:17 AM
  4. threads concept in java
    By vijji191 in forum Software Development
    Replies: 2
    Last Post: 30-11-2009, 03:44 PM
  5. Replies: 3
    Last Post: 12-09-2009, 09:48 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,400,749.87871 seconds with 17 queries