Text field shading every odd line


I have a "Text Field" that reads from a Map parameter "number" defined like this

String number = "first line \n second line \n third line";

I want to shade every second line like this:

Here is the definition of the "Text Field"

  <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                <reportElement x="110" y="77" width="110" height="11"/>
                <textElement verticalAlignment="Middle">
                    <font fontName="SansSerif" size="8" isBold="false"/>
                    <paragraph lineSpacing="Fixed" lineSpacingSize="10.0" leftIndent="2"/>

-> Is there a way to define it so that every odd line in the text field has a background color?

dunham's picture
Joined: Oct 18 2013 - 6:57am
Last seen: 1 week 2 days ago

2 Answers:


you can use table in basic element.

in the table style setup, remove all header and footer (if u dont need it). you can differ the odd row color by checking "use alternated detail rows background"


this one help me when i havent found the table element



hope that helps, cheers!


trvpseudo's picture
Joined: Jan 30 2019 - 11:02pm
Last seen: 1 week 1 day ago

You could also use a Conditional Style with just an expression like $V{REPORT_COUNT} % 2 == 0 to set another background color to your textfields. (be aware, not to define a separate background colör at textfield level itself just at the style level!)

Then you wont need a extra table component. 

hth + regards


C-Box's picture
Joined: Jul 19 2006 - 5:58pm
Last seen: 3 weeks 2 days ago