-1

i am creating jasper report for view the student details. i have a textfield if the enter correct student id relavent student details display on the jsper report below. i called the jsper report inside the jpanel. enter image description here

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. 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) {

        }
deva ram
  • 65
  • 8
  • When you debug the code, what values are being held in `a` after `a.put("id", txtno.getText());`? – lealceldeiro Dec 31 '19 at 12:25
  • sir i tested through the jsperviewer successfullly working but if i call this inside jpanel had problem for enter next id. i think refresh the report – deva ram Dec 31 '19 at 12:28
  • ("id", txtno.getText()) student id 3 displayed on txtno.getText() success – deva ram Dec 31 '19 at 12:31

1 Answers1

1

I think that revalidate() alone isn't enough to refresh the panel. You may reference to this link to make sure that repaint() is better to be called. I hope this helps you solve your problem.

P.S. You can swap the two lines before the last line.

Mohammed Deifallah
  • 1,290
  • 1
  • 10
  • 25