HOW-TO Reference a style that exists in a jrxml file

In the following fragment we create the titleStyle object with the name “titleStyle” and just leave it like this. The TemplateReportTestWithStyles.jrxml file has defined a style with the name titleStyle, thats why we see the report title with this coloring

 * "titleStyle" exists in the template .jrxml file
 * The title should be seen in a big font size, violet foreground and light green background
Style titleStyle = new Style("titleStyle");

Style subtitleStyle = new Style();
Style amountStyle = new Style(); amountStyle.setHorizontalAlign(HorizontalAlign.RIGHT);

DynamicReportBuilder drb = new DynamicReportBuilder();
drb.setTitle("November 2006 sales report")                                      //defines the title of the report
        .setDefaultStyles(titleStyle, subtitleStyle, headerStyle, detailStyle)

This code generate a report like this:

no images were found

Refer to TemplateStyleReportTest for a working example.

Overriding an existing style

If we need to override an existing style, just set the Style’s overridesExistingStyle property to true, this tells the DJ API to override any existing style with the same name with the new one.

Style titleStyle = new Style("titleStyle");