简体   繁体   English

java中的Jasper报告中只显示一次数据

[英]One time only data display on the Jasper report in java

i am creating jasper report for view the student details.我正在创建 jasper 报告以查看学生详细信息。 i have a textfield if the enter correct student id relavent student details display on the jsper report below.如果输入正确的学生 ID 相关学生详细信息显示在下面的 jsper 报告中,我有一个文本字段。 i called the jsper report inside the jpanel.我在 jpanel 中调用了 jsper 报告。 在此处输入图片说明

if i enter first time student id 3 it displayed result success then if i enter the second time student id 4 the same result shown.如果我第一次输入学生 id 3,它显示结果成功,然后如果我第二次输入学生 id 4,则显示相同的结果。 i don't know why.我不知道为什么。

  HashMap a = new HashMap();
        a.put("id", txtno.getText());

        try {

        JasperDesign jdesign = JRXmlLoader.load("C:\\Users\\kobinath\\Documents\\NetBeansProjects\\JavaApplication138\\src\\report1.jrxml");
        JasperReport jreport = JasperCompileManager.compileReport(jdesign);        
        JasperPrint jprint = JasperFillManager.fillReport(jreport, a, con);
         //  JasperViewer.viewReport(jprint);
         JRViewer vw=new JRViewer(jprint); 
         jPanel1.setLayout(new BorderLayout());
         jPanel1.repaint();

         jPanel1.add(vw);
         jPanel1.revalidate();



        } catch (JRException ex) {

        }

I think that revalidate() alone isn't enough to refresh the panel.我认为仅revalidate()不足以刷新面板。 You may reference to this link to make sure that repaint() is better to be called.您可以参考此链接以确保更好地调用repaint() I hope this helps you solve your problem.我希望这可以帮助您解决您的问题。

PS You can swap the two lines before the last line. PS 您可以在最后一行之前交换两行。

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

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