当 JasperViewer 出现并关闭它时,主框架/父级也关闭
当 JasperViewer
出现并且我关闭它时,主框架/父级也关闭了.如何预防?
When a JasperViewer
appear and I close it, the main frame / parent also closed. How to prevent this?
这是我的代码..
private void cmdprintidMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
try {
JasperDesign jasperDesign = JRXmlLoader.load("report12.jrxml");
String sql = "select * from db1 where Company LIKE '" + txtcompany.getText() + "%'";
JRDesignQuery newQuery = new JRDesignQuery();
newQuery.setText(sql);
jasperDesign.setQuery(newQuery);
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, conn);
JasperViewer.viewReport(jasperPrint);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
推荐答案
改变这个:JasperViewer.viewReport(jasperPrint);
to JasperViewer.viewReport(jasperPrint, false);
这将正常工作.
相关文章