Tips on Using Beans Effectively

Since JDE is becoming a bean-based tool there are things you should do when you are designing applications or applets in the current version of JDE.

For highlights on groups and shadows, generated code, and events, see A Groups and Shadows Quick Start Guide.

Customizing Component Properties

When you want to set or get a component property programmatically, you should code directly to the shadow's underlying AWT component or bean (the body) by using the getBody method.

Here is an example of how to set the label on an AWT component, such as a button:

     Button myButtonBody=(Button)gui.myButton.getBody();
     myButtonBody.setLabel("New Button Label");
     String theLabel=myButtonBody.getLabel();
Here is an example of how to call a method on a bean. In this example the bean is called Pinto.
     Pinto myPintoBody=(Pinto)gui.myPinto.getBody();
     myPintoBody.createBurrito("Hot sauce");

Adding Operations to AWT Components and Beans

You can add events to components and beans in the following ways:

The Message filters in the Filter dialog box does not translate well to the JDK 1.1 event style. You should use the JDK's event listener mechanism to implement the equivalent functionality.

Additional Information

For an overview of how beans are created and used in JDE, see Beans in JDE. The overview discusses the bean cycle from the creation of JAR files to the importation, the instantiation, and the updating of beans.

For an example of how to create and use beans in the JDE, see Tutorial Eight: Creating the Clock Project.