Adding a visual bean

When you add a bean, the mouse pointer changes when it is 'loaded' and positioned over a valid drop location within the Design page. Depending on which layout manager you are using, you may see other visual cues to guide your positioning of the bean. For example, for classes that implement a border layout, the Visual Editor labels different areas as North, East, South, West, and Center.

Some Java classes are also containers. For example, a JFrame class can have child components such as buttons, list boxes, and labels.

Adding a bean from a palette

Unless you have changed your preferences for the Visual Editor, the Design view provides bean palettes for different kinds of Swing and AWT components. You can expand and collapse these categories by clicking on the category. When a category is expanded, a 'pin open' icon palette pin is displayed to the right of the category name.

  1. Left-click the bean that you want to add. Do not hold down the mouse button. Note that when a bean is selected, the background area of its entry in the palette is shaded.
  2. Move the mouse pointer over to the Design page and click the mouse button again to drop the bean where you want it.

Adding a bean from a categorized list

  1. Click the down arrow next to the Choose Bean button on the main toolbar. A cascading menu offers four categories of beans for Swing and AWT components.
  2. Once you have selected a bean from one of the menus, move the mouse pointer to drop it in the Design page.

Adding a bean from a comprehensive list

  1. Click the Choose Bean button either in the Selection palette or on the main toolbar. The Choose a Bean dialog box opens.
  2. (Optional) Select Swing or AWT if you wish to restrict the list of beans that you are searching for.
  3. In the Class field, type part of the name of the bean that you are searching for. You can use wild cards, for example by typing *button to list all classes with the character string button anywhere in the name.
  4. As you type the characters that you want to filter for, the list of beans changes. This list includes all classes that are available in the Java build path for the Java project that contains the .java file you are editing.
  5. Select a class from the list and click OK. You are permitted to select only classes that include a null constructor because the Visual Editor for Java can instantiate only those classes that have default constructors.)
  6. Move the mouse pointer to drop the bean on the Design page.

The source page of the Visual Editor shows the Java code that is generated as you add each bean. Note: The Visual Editor's 'Choose beans' will allow you to drop JavaBeans that have null constructor in them (a JavaBean specification requirement). It will not allow you to drop Beans that use the static getInstance() pattern.

Related concepts
Visual Editor for Java
Containers and layout managers

Related tasks
Launching the Visual Editor for Java
Composing classes visually

(C) Copyright IBM Corporation 2000, 2003. All Rights Reserved.