Skip to end of metadata
Go to start of metadata

In XMA guidesigner, there exists no special support for fonts or font styles, like italic or bold.
If you want to use a specific font or font style, you have to use the font handling possibilities of SWT in your code.
The class ComponentClient of XMA runtime provides some methods to simplify font handling.
The main reason of these methods is to make all the needed disposing automatically by the runtime.
See also http://openxma.codehaus.org/docs/XMAGuide/programmersguide.html#resources.id5 for the font methods on the component.

How to

  • set the font of a widget
    This example shows how to set a font with its attributes to a widget.
    Overwrite the method createWidgets() and call super.
    In this method you create the new font by calling ComponentClient.getFont(name,height,style).
    Then you set this new font on the widget.
    If you changed the size of the widget, you have to call layout() on the composite containing the widget,
    so the overall layout is adjusted correctly.
    e.g.: to make the font of a widgets label 12pt Times:
    The font height has to be given in points.
    Possible styles are normal, italic, bold, bold&italic.
  • change the font size of a widget
    This example shows how to change only the size of a font, preserving its other attributes.
    Overwrite the method createWidgets() and call super.
    In this method you read the current font of the widget.
    Then you let the component make a font with the same attributes but different size by calling ComponentClient.getFontByHeight(template,height).
    Then you set this new font on the widget.
    Because you changed the size of the widget, you have to call layout() on the composite containing the widget,
    so the overall layout is adjusted correctly.
    e.g.: to make the font of a widgets label 12 points:
    The font height has to be given in points.
  • change the font style of a widget
    This example shows how to change only the style of a font, preserving its other attributes.
    Overwrite the method createWidgets() and call super.
    In this method you read the current font of the widget.
    Then you let the component make a font with the same attributes but different style by calling ComponentClient.getFontByStyle(template,style).
    At last you set this new font on the widget.
    e.g.: to make the font of a widgets label bold:
    Possible styles are normal, italic, bold, bold&italic.
  • change the font family of a widget
    This example shows how to change a font, while preserving its height and style.
    Overwrite the method createWidgets() and call super.
    In this method you read the current font of the widget and its font data.
    Then you create the new font by calling ComponentClient.getFont(name,height,style) and passing it the old height and style.
    At last you set this new font on the widget.
    e.g.: to change the font to "Times" while preserving height and style:
Labels
  • None