开发者

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

I'm a newbie in using JasperReports. In my Swing application I want t开发者_高级运维o show JRViewer inside a JPanel or JFrame.

Can anyone help me out?


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);


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜