Adding a Bitmap for a Control

As part of the visual representation of your control, you can assign a 16-by-16-pixel bitmap to it. The bitmap is displayed in the Visual J++ Toolbox when your control is available. The bitmap is also displayed for controls that do not have a run-time representation, such as timers.

Note   The bitmap is used only if the control is being used as a WFC control. If used as an ActiveX control, the control displays a standard, predefined bitmap in the toolbox.

By default, the ClassInfo object loads any bitmap that has the same file name as your control. If your control is named MyControl.java, you can associate a bitmap with it by just adding MyControl.bmp to the folder where your MyControl.class file is.

Alternatively, you can specify a particular bitmap by overriding the getToolboxBitmap method in your ClassInfo subclass. The following example shows how you can assign the bitmap Gears.bmp to your control:

public Bitmap getToolboxBitmap(){
   return = new Bitmap(MyControl.class, "Gears.bmp");
}

The bitmap you specify should be no more than 16-by-16 pixels in size, and should use 16 colors or fewer. Visual J++ can automatically resize a bitmap that is not of the correct dimensions, but this often results in a graphic that does not look good.