基本上我想从我的主应用程序上的按钮调用JasperViewer.
我用这个
private void btnExportActionPerformed(java.awt.event.ActionEvent evt) {
try {
JasperPrint printer = JasperFillManager.fillReport(getClass().getResourceAsStream("reportRecharge.jasper"), params, new JREmptyDataSource());
JasperViewer jv = new JasperViewer(printer);
jv.setVisible(true);
} catch (JRException ex) {
ex.printStackTrace();
}
}
当JasperViewer出现并关闭时,主框架/父框架也关闭.我尝试添加jv.setDefaultCloseOperation(HIDE_ON_CLOSE);但它也没有用.怎么弄?
任何帮助,将不胜感激.
解决方法:
改变如下.如果添加false,则close属性上的默认出口将变为false.
private void btnExportActionPerformed(java.awt.event.ActionEvent evt) {
try {
JasperPrint printer = JasperFillManager.fillReport(getClass().getResourceAsStream("reportRecharge.jasper"), params, new JREmptyDataSource());
JasperViewer jv = new JasperViewer(printer,false);
jv.setVisible(true);
} catch (JRException ex) {
ex.printStackTrace();
}
}