简体   繁体   中英

Jasper Report not display in jdesktoppane

I am new to java. I tried to display jasper Report in Jdesktoppane but report Does not display in jdesktoppane.I cant get any error or Exception while run the program how to slove this problem.. Any one help me to display report in jdesktoppane

private void Report() {

 try
   {  

      JasperDesignjd=JRXmlLoader.load("F:\\NetBeans\\Project\\Chit\\src\\Report\\report1.jrxml");
      JasperReport jr=JasperCompileManager.compileReport(jd);  
      JasperPrint  jp=JasperFillManager.fillReport(jr, null,chit1.conn);
      JRViewer viewer = new JRViewer(jp); 
      jPanel1.add(viewer); 
      jPanel1.setVisible(true);
      jDesktopPane.add(viewer); 

   }  
 catch (JRException ex) 
    {
        System.out.println(ex);

    }

}

Thank you..

You have to add a JInternalFrame to the JDesktopPane (JPanel1 I assume). I have added a JScrollPane to provide scrolling. Not sure whether needed.

JInternalFrame frame = new JInternalFrame("Report", true, true, true, true);
frame.add(new ScrollPane(viewer));
try {
    frame.setSelected(true);
 } catch (java.beans.PropertyVetoException e) {
 }

I assume the rest (JFrame) is fine.

I got the step to display jasper Report

Create Jinternal Frame add below code and then add to JdesktopPane here is the code:

private void Report() { 

    try  { 
        Connection dataSource = chit1.conn; 
        JasperDesign jd=JRXmlLoader.load("F:\\Net Beans\\Project\\Chit\\src\\Report\\report1.jrxml"); 
        JasperReport report=JasperCompileManager.compileReport(jd); 
        JasperPrint jasperPrint = JasperFillManager.fillReport(report, null, dataSource); 
        JRViewer viewer = new JRViewer(jasperPrint); 
        Container c= getContentPane(); 
        c.setLayout(new BorderLayout()); 
        c.add(viewer); 
       }  catch (JRException ex)  { 
       System.out.println(ex); 
       Logger.getLogger(MemberReport.class.getName()).log(Level.SEVERE, null, ex); 
     } 
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM