Skip to content

Instantly share code, notes, and snippets.

@edilsoncichon
Created June 27, 2017 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edilsoncichon/9147b75df8e1a3992983b91788f14e03 to your computer and use it in GitHub Desktop.
Save edilsoncichon/9147b75df8e1a3992983b91788f14e03 to your computer and use it in GitHub Desktop.
Solution for working with modal window and JasperReport / iReport. / Solução para se trabalhar com janela modal e JasperReport/iReport.
public void gerarReport(String filePath, List list) throws Exception {
JDialog dialogReport = new JDialog(new javax.swing.JFrame(), "TITLE REPORT", true);
dialogReport.setSize(1000, 700);
dialogReport.setLocationRelativeTo(null);
InputStream fileReport = getClass().getResourceAsStream(filePath);
Map params = new HashMap();
JRBeanCollectionDataSource dataList = new JRBeanCollectionDataSource(list);
JasperPrint print = JasperFillManager.fillReport(fileReport, params, dataList);
JasperViewer windowJasper = new JasperViewer(print, true);
dialogReport.getContentPane().add(windowJasper.getContentPane());
if ( print.getPages().size() > 0 )
dialogReport.setVisible(true);
else
throw new Exception("No Pages!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment