-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChamaRelatorio.java
31 lines (24 loc) · 1007 Bytes
/
ChamaRelatorio.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
*
* @author Mateus Moreira
*/
public class ChamaRelatorio {
public void ChamandoRelatorio(){
try {
EntityManager em = EntityManagerUtil.getEntityManager();
List<Classe> lista = em.createQuery("from Classe").getResultList();
HashMap<String, Object> parametros = new HashMap<String, Object>();
String relatorio = "/../home/caminho/caminho/caminho/caminho/Classe.jasper";
JRDataSource dataSource = new JRBeanCollectionDataSource(lista);
JasperPrint impressao = JasperFillManager.fillReport(relatorio, parametros, dataSource);
JDialog viewer = new JDialog(new javax.swing.JFrame(), "Visualização do Relátorio", true);
viewer.setSize(1024, 768);
viewer.setLocationRelativeTo(null);
JasperViewer jrviewer = new JasperViewer(impressao, true);
viewer.getContentPane().add(jrviewer.getContentPane());
viewer.setVisible(true);
} catch (JRException ex) {
System.out.print("Erro: " + ex.getMessage());
}
}
}