Java Reference
In-Depth Information
Adding Rectangles to a Report
Adding a rectangle to a report can be achieved by using the JRXML <rectangle>
element. A rectangle simply outlines the area defined by its <reportElement> sub-
element. We can create rectangles with round corners by setting the radius property
of the <rectangle> element. The following JRXML template illustrates how to create
rectangles in a report:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//
EN" "">
<jasperReport name="RectangleDemoReport">
<band height="100">
<reportElement x="0" y="0" width="555" height="30"/>
<rectangle radius="5">
<reportElement x="0" y="70" width="555" height="30"
<graphicElement pen="4Point"/>
After compiling the above JRXML template, and filling the resulting binary Jasper
template, we should see a report like the following:
Notice how the line outlining the second rectangle is thicker than the first one. This
is because we used the <graphicElement> sub-element of the <rectangle> element.
Just as every text element can contain a <textElement> sub-element, every graphic
element can contain a <graphicElement> sub-element.
Search WWH ::

Custom Search