Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more ➡
Standard view
Full view
of .
Add note
Save to My Library
Sync to mobile
Look up keyword
Like this
0 of .
Results for:
No results containing your search query
P. 1
Basic Bean Concepts

Basic Bean Concepts

Ratings: (0)|Views: 75|Likes:
Published by mmmaheshwari

More info:

Published by: mmmaheshwari on Dec 23, 2012
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, DOC, TXT or read online from Scribd
See More
See less





JavaBeans™ is a portable, platform-independent component model written in the Java programming language. The JavaBeans architecture was built through a collaborative industryeffort and enables developers to write reusable components in the Java programming language.With the JavaBeans API you can create reuseable, platform-independent components. UsingJavaBeans-compliant application builder tools, you can combine these components into applets,applications, or composite components.JavaBean components are known as
. Beans are dynamic in that they can be changed or customized. Through the design mode of a builder tool, you use the property sheet or beancustomizer to customize the bean and then save (persist) your customized beans.
Lesson: Using the NetBeans GUI Builder 
This lesson explains how to use the NetBeans IDE GUI Builder to work with beans. In preparationfor working with the GUI Builder, you should be first familiar with the key NetBeans conceptswhich are explained in the  NetBeans IDE Java Quick Start Tutorial.  This lesson guides you through the process of creating a bean pattern in the NetBeans projects,introduces the user interface of the GUI Builder, and explains how to add your bean object to the palette.
Creating a New Project
In the NetBeans IDE, you always work in a project where you store sources and files. To create anew project, perform the following steps:1.Select New Project from the File menu. You can also click the New Project button in theIDE toolbar.2.In the Categories pane, select the General node. In the Projects pane, choose the JavaApplication type. Click the Next button.3.Enter MyBean in the Project Name field and specify the project location. Do not create a
class here, because later you will create a new
class in this project.4.Click the Finish button.This figure represents the expanded MyBean node in the Projects list.
Creating a New Form
After creating a new project, the next step is to create a form within which the JavaBeanscomponents and other required GUI components, will be placed.To create a new form, perform the following sequence of actions:1.In the Projects list, expand the MyBean node, right-click on the <default package> nodeand choose New|JFrame Form from the pop-up menu.2.Enter MyForm as the Class Name.3.Click the Finish button.The IDE creates the MyForm form and the MyForm class within the MyBean application andopens the MyForm form in the GUI Builder.This figure represents the Projects list, where the MyForm class is located.
The GUI Builder Interface
When the JFrame form is added to your application, the IDE opens the newly-created form in anEditor tab with a toolbar containing the following buttons:
 – Selection Mode enables you to select one or more objects in the Design Area.
 – Connection Mode enables you to set a connection between objects by specifying anevent.
 – Preview Design enables you to preview the form layout.
 – Align commands enable you to align selected objects.
 – Change Resizability enables you to set up vertical and horizontal resizing.When the MyForm form opens in the GUI Builder's Design view, three additional windowsappear, enabling you to navigate, organize, and edit GUI forms. These windows include thefollowing:
Design Area
. The primary window for creating and editing Java GUI forms. Source andDesign toggle buttons enable you to switch between view a class's source code and agraphical view of the GUI components. Click on an object to select it in the Design Area.For a multiple selection, hold down the Ctrl key while clicking on objects.
. Representation of a tree hierarchy of all the components in your application.The Inspector highlights the component in the tree that is currently being edited.
. A customizable list of available components containing groups for Swing, AWT,Borders, and Beans components. This window enables you to create, remove, andrearrange the categories displayed in the palette using the customizer.
Properties Window
. A display of the properties of the component currently selected in theGUI Builder, Inspector window, Projects window, or Files window.If you click the Source button, the IDE displays the application's Java source code in the editor.Sections of code that are automatically generated by the GUI Builder are indicated by blue areas.These blue areas are protected from editing in the Source view. You can only edit code appearingin the white areas of the editor when in Source view. When you make your changes in the DesignView, the IDE updates the file's sources.
Creating a Bean
To create your own bean object and add it to the palette for the bean group, execute the following procedure:1.Select the <default package> node in the MyBean project.2.Choose New|Java Class from the pop-up menu.3.Specify the name for the new class, for example, MyBean, then press the Finish button.4.Open the MyBean.java file.5.In the editor window, select inside the class. Right-click and choose Insert Code. Thenselect Add Property.6.In the Name field of the Add Property dialog box, type YourName and press OK.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->