Java Reference
In-Depth Information
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN"
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="TextFieldStretchDemo" >
<field name="lots_of_data" class="java.lang.String"/>
<detail>
<band height="55">
<textField isStretchWithOverflow="true">
<reportElement x="0" y="0" width="100" height="24"/>
<box border="Thin"/>
<textFieldExpression class="java.lang.String">
<![CDATA[$F{lots_of_data}]]>
</textFieldExpression>
</textField>
<staticText>
<reportElement width="500" y="25" x="0" height="30"
positionType="FixRelativeToTop"/>
<box border="Thin"/>
<text>
<![CDATA[This staticText element has a default positionType
of "FixRelativeToTop"]]>
</text>
</staticText>
</band>
</detail>
</jasperReport>
The <textField> element in the JRXML template has a y position of 0 , and a height
of 24 . We positioned the new <staticText> element to have a y position of 25 , just
below the < textField> .
For clarity, we explicitly set the positionType attribute
of <reportElement> to FixRelativeToTop . It was not
really necessary to do it, since FixRelativeToTop is the
default value.
Notice the <box> element we added to the <textField> and <staticText>
elements. This <box> field allows us to display a border around the elements,
making it very clear where the element starts and ends. We chose to do this to be
able to easily see the position of the elements within the report.
 
Search WWH ::




Custom Search