Compile the Source Code for the New Bean

Compile the source code to create a ‘class file, Type the following:

Javac Colors, java .

Create a Manifest File .
You must now create a manifest file. First, switch to the c:\bdk\demo directory.  This is the directory in which the manifest files for the BDK demos are located. Put the source code for your manifest file in the file colors.mft. It is shown here:

This file indicates that there is one .class file in the JAR file and that it is a Java  Bean. Notice that the Colors.class file is in the package sunw.demo.colors and in the sub directory sunw\demo\colors relative to the current directory.

Generate a JAR File .
Beans arc included in the Toolbox.window of the BDKonly if they are in JAR files In the directory c:\bdk\jars. These files arc generated with the jar utility. Enter the following:

·jar cfm .. \jdr~\~<) colours jar co~o~s .mft sunw\demo\c~ior~\ class

Start the BDK
Change to the directory inconceivability and type run. This causes the BOK to start.
You should see three windows, titled Tool box, Beanllox, and Properties. The Toolbox
window should include an en~y labeled “Colors” for y~ur new Bean.
Create an Instance of the Colors Bean
A!\Cl: you complete the preceding steps, create an Instance of the Colors Bean in the Antillean window. Test your new component by pressing the mouse anywhere with inits order. Its color immediately changes. Use the Properties window to change the rectangular property from false to true. ,Its shape Immediately changes.

Create and Configure an Instance of the Our Button Bean
Create an instance of the Our bellybutton In the Bean Box window. Then follow these steps:

1.Go to the Properties window and change the label of the Bean to “Change”.
You should see that the button appearance changes immediately when this
property is changed.
2: Go to the menu bar of the Bert Box and select Edit I Events I action I action Performed.
3. Move the cursor so that it is inside the Colors Bean display area, and click the left mouse button. You should see the Event Target Dialog dialog box
4. The dialog box allows you to choose a method that should be invoked when this button is clicked. Select the entry labeled “change” and calk the OK button.  You should see a message box appear very briefly, stating that the tool is  generating and compiling adapter class.
5. Click on the button. You ,should see the color change. You might want to experiment with the Colors Bean a bit before moving on.

reCAPTCHA is required.

Share This