views:

274

answers:

1

Hi everyone,

i'm a newbie in using jasperreports. In my swing application i wanna show jasper viewer inside a jpanel or jframe..! can anyone help me out..?

Thanks in advance...!

A: 
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);
darri