Creating a Bean Project

JavaBeansTM are reusable software components that you write once and can use anywhere. To create JavaBeans that can be imported into the GUI builder palette, you will need to create a beans project (or projects) that contains the individual beans.

A JavaBeans project can contain a single bean or multiple beans. When a bean project is built, a single JAR file is generated which contains all of the beans in the bean project. To reduce the time of loading the JAR file in the GUI builder, unrelated beans should be created in separate bean projects.

The files you can create using the Create Project wizard include:

To create a bean project:

  1. Click the Projects button on the Java WorkShop main toolbar.
  2. Double-click on the portfolio name where you want the bean project to be placed.
    You can create a bean project in any portfolio for which you have write permission.
  3. In the project manager, choose File -> New -> Project.
    The Create Project wizard is displayed.
  4. Type the name of your project in the box where untitled appears.
    Make sure you are consistent in the use of capitalization in project and file names; Java WorkShop is case-sensitive.
  5. Click the Beans radio button.
  6. Click Next.
  7. Type the project's package name, using the sun.jws.browse format, in the Package name box.
    Completing this text box is necessary for a beans project.
  8. In the Root directory box, type the directory where the package's class hierarchy is located.
    Completing this text box is optional.
  9. If you want to keep the source files in a directory other than the default listed in the box, replace the project storage default directory with the directory you want to use.
  10. Decide if you have existing files you want to add to the project.

Adding a Bean

This is the part where you actually create the bean that will go in your project.
  1. Type the name of your bean into the Bean Name box.
    The name of the bean can be one of the following:
  2. Decide if you want the bean to have an accompanying BeanInfo file and/or a Customizer file, and select the appropriate checkbox(es).
    You can select both the BeanInfo check box and Customizer check box, or just one, depending on your component plan.
  3. Click Create New Java Bean.
    Java WorkShop automatically adds the .java suffix to each bean file name, and adds the file to the Java Files list.
  4. Decide if you want to add another bean to this project.

    Java WorkShop creates source templates for each non-existing file in the New Bean Card list. The source editor shows the source code for the project's first file. And, the project is added to the project manager.

JavaBeans are packaged and distributed within JAR files. After successfully compiling and building a bean project, a single JAR file is created for the project containing all of the classes and resources needed by the beans in the project.

When the project is built, Java WorkShop adds the following to the JAR file:

Although a JAR file can contain more than one bean, having separate JAR files for unrelated beans is recommended.

You can change the default attribute values for the project by choosing Edit -> Project. See Editing Project Attributes for information.

See also:

Beans In Java WorkShop
Importing Components (includes importing a JAR File)
Creating an Applet Project
Creating a Standalone Program Project
Creating a Java Package Project
Using the Create Project Wizard