Jasper Viewer Header

This is how I show the Jasper report in swing applications.

 JasperViewer.viewReport(jasperPrint, true);

Then, when the report is being viewed, the title of the report view is "Jasper Viewer". I want to change it and set my own name. My other question is how to directly send a report to print without viewing. Please give some sample code. Thank.

+5
source share
2 answers

JasperViewer.viewReport(...)- This is a wrapper class that creates and displays JasperViewer JFramewith a panel JRViewer.

Using this method, you cannot access the base JFrame, so you cannot change the frame title.

JasperViewer, , setTitle(...).

- JDialog JRViewer.

:

final JRPrintServiceExporter exporter = new JRPrintServiceExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PAGE_DIALOG, Boolean.FALSE);
exporter.setParameter(JRPrintServiceExporterParameter.DISPLAY_PRINT_DIALOG, Boolean.TRUE);
exporter.exportReport();
+6

:

        JasperViewer jv = new JasperViewer(jasperPrint, false);
        jv.setTitle("Report-Title");
        jv.setVisible(true);

, JasperViewer - JFrame -

public class JasperViewer extends JFrame{
   //...
}
+6

All Articles