简体   繁体   English

Jasper报表未显示在jdesktoppane中

[英]Jasper Report not display in jdesktoppane

I am new to java. 我是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 我试图在Jdesktoppane中显示jasper报告,但报告未显示在jdesktoppane中。运行程序如何解决此问题时,我无法得到任何错误或异常。任何人都可以帮助我在jdesktoppane中显示报告

private void Report() { 私人无效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). 您必须将JInternalFrame添加到JDesktopPane(我假设为JPanel1)。 I have added a JScrollPane to provide scrolling. 我添加了一个JScrollPane以提供滚动。 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. 我认为其余的(JFrame)都很好。

I got the step to display jasper Report 我迈出了显示碧玉报告的步骤

Create Jinternal Frame add below code and then add to JdesktopPane here is the code: 创建Jinternal Frame,添加以下代码,然后将以下代码添加到JdesktopPane:

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); 
     } 
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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