Managing the Toolbox

   Tasks

The Toolbox provides a list of controls that are currently available. These controls can be Windows Foundation Classes for Java (WFC) controls, ActiveX controls, or HTML intrinsic controls. You can use them to design your forms and HTML pages. The Toolbox can also be used to store collections of controls that you copy from your form and source code and want to reuse in your current project or in other projects. The Toolbox provides tabs for grouping related controls. You can then use these tabs to navigate among the different types of controls and objects. Using the Toolbox makes finding and organizing your controls and objects easier.

Adding a Control to the Toolbox

By default, all WFC controls provided by Visual J++ are listed in the Toolbox. You can also add controls that you have created or purchased from a third party.

To add a control to the Toolbox

  1. In the Toolbox, click the tab that you want to add a control to.

  2. On the Tools menu, click Customize Toolbox.

  3. Select the tab that represents the type of control that you want to add.

    For example, if you want to add a WFC control that you created, click the WFC Controls tab (which is shown by default).

  4. Select the controls that you want to add to the Toolbox and click OK.

Note   In order for a WFC control to be displayed in the Toolbox, it must extend com.ms.wfc.core.Component and have its ShowInToolbox attribute set to true.

Copying Controls to the Toolbox

While designing a user interface for a form, you may find that you want to reuse a group of controls and their property settings in a different form or in a different project. Use the Toolbox to store groups of controls to reuse later.

To copy controls from a form to the Toolbox

  1. Open the form that contains the controls that you want to copy.

  2. Select the controls.

  3. On the Edit menu, click Copy.

  4. Select the Toolbox tab that you want to paste the controls into.

  5. In the Toolbox, click the right mouse button, and choose Paste on the context menu.

    A new Toolbox item is added called "Form Fragment." You can rename the form fragment by right-clicking the item and clicking Rename.

    After you have the group of controls in the Toolbox, you can add them to a form just as you would any other control.

Copying Source Fragments to the Toolbox

In addition to copying controls to the Toolbox, you can also copy fragments of code. You can copy routines that you use frequently and apply them to other projects.

To copy source code fragments to the Toolbox

  1. Open the source file that you want to copy a section of source code from into the Text editor. This can be a Java source file, an HTML page, or a standard text file.

  2. Select the code that you want to copy.

  3. On the Edit menu, click Copy.

  4. In the Toolbox, click the right mouse button, and choose Paste on the context menu.

    A new Toolbox item is added called "Text Fragment." You can rename the text fragment by right-clicking the item and clicking Rename.

Adding a Tab to a Toolbox

Although Visual J++ provides a variety of tabs in the Toolbox, you can also create your own tabs. In addition, you can use tabs to group Toolbox items that are used in your project. For example, if your project uses ActiveX and WFC controls to build its user interface, you can create a tab and have all the controls that you use displayed as a group.

To add a tab to the Toolbox

  1. In the Toolbox, click the right mouse button, and then click Add Tab on the context menu.

  2. Type a caption for the tab and press ENTER.

    You can now select the tab and add controls and objects to it.

Copying and Moving Toolbox Items

After you have created a tab, you can then add Toolbox items to it and move items that are located on other tabs to your new tab. In addition to moving controls between tabs, you can also copy controls from one tab to another. You can then store the same controls in more than one group.

To move a Toolbox item between tabs

To copy a Toolbox item to another tab

Renaming a Tab in the Toolbox

After you have created a tab, you can change its caption.

To rename a tab in the Toolbox

  1. Click the right mouse button in the tab that you want to rename, and then click Rename Tab on the context menu.

  2. Type a new caption for the tab and press ENTER.

Changing the Toolbox View

By default, each Toolbox item is displayed with a symbol that represents the control. Although you can move the mouse over the control to display its name, you may want to see a list of item names. Use List View mode to view a list of controls.

To view Toolbox items as a list

Deleting Toolbox Items

You can remove items from the Toolbox so that it is less cluttered. You can also remove copies of controls that you have placed on different tabs.

Note   Deleting controls from the Toolbox does not remove the control from your form, and it can be added back to the Toolbox. For information, see "Adding a Control to the Toolbox" earlier in this topic.

To delete items from the Toolbox