This question already has an answer here:
- How to prevent parent frame closed when closing child frame (Java + iReport)? 1 answer
When a JasperViewer
appear and I close it, the main frame / parent also closed. How to prevent this?
This is my code..
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);
}