Changing bean colors and fonts

Another enhancement that you can make to your visual beans is to change the colors and fonts that the beans use.

If you are developing applets to be used on multiple platforms, you should carefully consider the effect of choosing colors and fonts that are different from the default system colors and fonts. For example, if you choose a particular font available in OS/2, that font might not be available in Windows. For more information, see Portability of colors and fonts.

Changing the color of a bean

  1. In the Visual Composition Editor, double-click on a JButton bean whose color you want to change. The Properties window appears.
  2. To change the background color of a bean, select the value for the background property in the Property window. Select the button that appears:

    The Backgound window opens:

    tjgscolo.gif (4949 bytes)

  3. In the Background window, click mouse button 1 on the color you want to use. The color appears in the color pane. Then select OK.

Now double-click on a JLabel bean. Follow the same steps, again choosing the background property. This time a slightly different window appears, as shown below. To alter colors, use the slider controls, or select Basic or System and choose a color.

tjgscol2.GIF (4632 bytes)

Note:
You cannot change the color of beans in Menus.

Changing the font of a bean

  1. In the Visual Composition Editor, double-click on the bean whose font you want to change.
  2. In the Properties window that opens, select the value of the font property. Select the  button that appears in the value column for font.

    The Font window opens:

    tjgsfont.gif (3434 bytes)

  3. Using the Name drop-down list, select the font you want to use.
  4. Using the Style and Size choices, select the size and style you want to use. A sample of the font you have selected is displayed in the text area. You can type additional text in this area to see the appearance of various characters.
  5. When you have finished specifying the font, select OK. The selected font is shown in the value column for font.

Note:
Some beans, such as Menu beans, may not support the changing of fonts depending on the target platform.

Portability of colors and fonts

If your applet will be used on multiple platforms, the colors and fonts of the beans must be available on all systems that will run your applet.

If you do decide to change the colors of beans in your applet, use only basic colors in the window, since non-basic colors may appear differently on different platforms.

If you decide to change the font of a bean, ensure that the font you choose will be available on all the systems that will be running the finished program. You might also have problems with certain fonts if your applet will be run on systems that use code pages designed for languages other than English.