How to display JasperReports Viewer inside JPanel / JFrame ..?

I am new to using JasperReports . In my Swing app, I want to show a JRViewer inside a JPanel or JFrame .

Can anyone help me out?

+7
java swing jasper-reports
source share
2 answers
 JRDataSource dataSource = ...; Map parameters = new HashMap(); parameters.put("id", 42); JasperReport report = (JasperReport) JRLoader.loadObject("c:/reports/report.jasper"); JasperPrint jasperPrint = JasperFillManager.fillReport(report, parameters, dataSource); JFrame frame = new JFrame("Report"); frame.getContentPane().add(new JRViewer(jasperPrint)); frame.pack(); frame.setVisible(true); 
+19
source share

The JRViewer class is a subclass of javax.swing.JPanel , so treat it like a normal JPanel and do your stuff.

+1
source share

All Articles