Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Java Swings

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wink Java Swings

    Can anyone please help me in correcting the following code:

    package APackage1;
    import java.awt.Container;
    import java.util.HashMap;
    import net.sf.jasperreports.swing.JRViewer;
    import net.sf.jasperreports.engine.*;
    public class AViewer extends javax.swing.JFrame
    {
    public AViewer(String fileName)
    {
    this(fileName,null);
    }

    /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

    setDefaultCloseOperation(javax.swing.WindowConstan ts.EXIT_ON_CLOSE);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGap(0, 400, Short.MAX_VALUE)
    );
    layout.setVerticalGroup(
    layout.createParallelGroup(javax.swing.GroupLayout .Alignment.LEADING)
    .addGap(0, 300, Short.MAX_VALUE)
    );

    pack();
    }// </editor-fold>

    public AViewer(String fileName,HashMap parameter)
    {
    super("View Report");
    try
    {
    JasperPrint print = JasperFillManager.fillReport
    ("C:/Documents and Settings/c.smith/Desktop/Gayu/report2.jasper", parameter);
    JRViewer viewer=new JRViewer(print);
    Container c=getContentPane();
    c.add(viewer);
    }

    catch(JRException jre)
    {
    jre.printStackTrace();
    }

    setBounds(10,10,600,500);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);


    }
    public static void main(String args[])
    {
    HashMap parameter=new HashMap();
    parameter.put("productID",1);
    parameter.put("samplenum",123.55);
    parameter.put("sampledt",17/10/2011);
    AViewer viewer=new AViewer("C:/Documents and Settings/c.smith/Desktop/Gayu/report2.jasper",parameter);
    viewer.setVisible(true);
    }
    }


    // Variables declaration - do not modify
    // End of variables declaration

    I am trying to display a Jasper Report file through a Java application. In this code, the JFrame is getting loaded, but the report is not. I am getting an error Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException. I dont understand why. This is the first time I am working with Jasper Reports, so please help me. And, am using NetBeans IDE 7.

    Thanks.
    Last edited by rosebrit3; October 19th, 2011 at 06:44 AM.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Java Swings

    When posting code, please use the highlight tags. See any "read this before posting" article for information on how to do that.

    Do you have your classpath set up correctly?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. [SOLVED] Can anyone mail me an e-book on Swings?
    By Lord Voldemort in forum AWT / Java Swing
    Replies: 3
    Last Post: July 4th, 2011, 07:57 AM

Tags for this Thread