I have a problem when viewing 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 show it to me, but when I run my application on another machine and click on the jButton
, that report is not shown in Jpanel
and it does not mark me an error, it only stays blank my Jpanel
and it does not even show the menus above where you can zoom etc.
This is the report generated:
The code I use in the JButton ActionPerformed is as follows:
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);
}