I have a problem when displaying one of my reports in a Jpanel of my graphical interface.
It is worth mentioning that the report that gives me problems, I can see it on my machine even after opening it in the interface of my application that is already generated, that is, I open my app.jar
, I click on a jButton
to generate the report, called "Caratula" and it shows it to me, but when I run my application on another machine and click on jButton
it, said report is not shown in Jpanel
it and it does not show me an error, it just stays blank Jpanel
and does not even show the menus above where it can be done zoom etc
This is the generated report:
The code I use in the ActionPerformed of the JButton is the following:
try {
//Aquí obtengo la fecha que uso en uno de los parametros...
Calendar cal = dateChooserComboFechaCaratula.getSelectedDate();
Date date = cal.getTime();
SimpleDateFormat formatFechaSQL = new SimpleDateFormat("yyyy-MM-dd");
String fechaFin = formatFechaSQL.format(date);
String dir_current = System.getProperty("user.dir") ;
String file_report = dir_current+"/Reportes/Caratula/Cartula_general.jasper";
String dir_mañana = dir_current+"/Reportes/Caratula/caratula_mañana/";
String dir_tarde = dir_current+"/Reportes/Caratula/caratula_tarde/";
String noche_1 = dir_current+"/Reportes/Caratula/Caratula_noche_1/";
String dir = dir_current+"/Reportes/Caratula/";
String noche_2 = dir_current+"/Reportes/Caratula/Caratula_noche_2/";
String gasolin = dir_current+"/Reportes/Caratula/gasolinera/";
File fichero = new File(file_report);
JasperReport jr;
jr = (JasperReport) JRLoader.loadObject(fichero);
Map parameters = new HashMap();
parameters.put("SUBREPORT_DIR_MAÑANA",dir_mañana);
parameters.put("SUBREPORT_DIR_TARDE",dir_tarde);
parameters.put("SUBREPORT_DIR_NOCHE_1",noche_1);
parameters.put("SUBREPORT_DIR",dir);
parameters.put("SUBREPORT_DIR_NOCHE_2",noche_2);
parameters.put("SUBREPORT_DIR_GASOLINERA",gasolin);
parameters.put("fecha", fechaFin);
JasperPrint jasperprint = JasperFillManager.fillReport(jr,parameters, DbConexion.getConnection());//new JREmptyDataSource()
JasperViewer jviewer = new JasperViewer(jasperprint);
refrescar_Ventana();
jPanel2.removeAll();
jPanel2.add(jviewer.getContentPane(), BorderLayout.CENTER);
} catch (JRException ex) {
System.out.println(ex);
JOptionPane.showMessageDialog(JIFCaratula.this,ex, "Error", JOptionPane.ERROR_MESSAGE);
JOptionPane.showMessageDialog(JIFCaratula.this, "No fue posible generar el reporte, revise que las rutas sean las adecuadas", "Error", JOptionPane.ERROR_MESSAGE);
}