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 ...