在一帧上按钮的点击事件我写了这段代码
JasperPrint jasperPrint = new business_logics.Client().generateReport(this);
Report report = new Report(jasperPrint);
,核心代码就像这样
public JasperPrint generateReport(Component o) {
try {
JasperPrint jasperPrint = null;
if (hm == null) {
hm = new HashMap();
}
try {
String source="Client.jasper";
jasperPrint = JasperFillManager.fillReport(source, hm, new ConnectionSeeker().giveConnection(o));
} catch (JRException e) {
System.err.println(""+e.getMessage());
}
return jasperPrint;
} catch (Exception ex) {
System.err.println(""+ex);
return null;
}
}
我想要显示JRViewer的框架是这样的:
public class Report extends javax.swing.JFrame {
private JRViewer viewer;
public Report(JasperPrint j) {
initComponents();
viewer = new JRViewer(j);
add(viewer);
pack();
this.setVisible(true);
}
}