0
votes

I am trying to instantiate a JRDesignChartDataset object so that I can pass it in to the constructor of a JRDesignPieDataset instance like so:

JRDesignPieDataset pieDataset = new JRDesignPieDataset(new JRDesignChartDataset());

This produces a compiler error in Eclipse, complaining that it Cannot instantiate the type JRDesignChartDataset...?!?!

I've made sure that I've imported it from the correct package:

import net.sf.jasperreports.engine.design.JRDesignChartDataset;

And I've checked the current (4.1.3) Javadocs which show this is as a concrete class with a public no-args constructor...

All of the otther JR types that I am importing from the net.sf.jasperreports.engine.design package are behaving perfectly fine...what am I missing here?

Thanks in advance!

1
OK I was able to verify that this is in fact an abstract class, which technically answers my question. However I still cannot instantiate my JRDesignPieDataset, because its only valid constructor takes a JRDesignChartDataset subclass...but JRDesignPieDataset is a JRDesignChartDataset!!! Thats like a Car class that takes a Vehicle as a constructor parameter! Can someone please give me a valid example of how to instantiate a JRDesignPieDataset?IAmYourFaja

1 Answers

0
votes

This may not be the recommended practice, but I've inherited some code that simply passes null into the constructor. Not sure what effect it has (if any), but it seems to get the job done.

JRDesignPieDataset data = new JRDesignPieDataset(null);