Java Reference
In-Depth Information
Clicking on the
Generate Report
button will generate the report in JasperReports'
native format, and display it on the screen, ready for printing.
This window should look familiar. What we are seeing here is the same application
we used before to view reports in JasperReports' native format. The only difference
is that instead of invoking the application from an ANT script, we invoked it
programmatically from our code. The class in question is
net.sf.jasperreports.
view.JasperViewer
. Its constructor takes a
JasperPrint
object as its only
parameter. A
JasperPrint
object is an in-memory representation of a report
in JasperReports' native format.
JasperViewer
extends
javax.swing.JFrame
;
therefore, to make it visible, all we need to do is call its
setVisible()
method,
passing the Boolean value
true
as a parameter. The
displayReport()
method in the
preceding example illustrates this procedure.