O'Reilly logo

JasperReports 3.5 for Java Developers by David Heffelfinger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

TableModels as datasources

In many client-side applications, data is displayed in tabular format. A common requirement in many applications is to allow the user to print this tabular format as a report.

JasperReports provides an implementation of the JRDataSource interface that makes the task of generating reports from tabular format trivial for Swing applications. The class in question is net.sf.jasperreports.engine.data.JRTableModelDataSource. This class takes a javax.swing.table.TableModel as its only parameter. Because tables in Swing are populated through TableModels, all we need to do for generating a report from a table is to pass the appropriate table's TableModel as a parameter. The following example is a simple but complete Swing application ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required