0

我已将 JFreeChart 演示的代码复制并创建到我在项目中创建的类中。

java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: (<any>)void当我尝试编译代码时收到一个。

完整的错误如下:

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code -      Erroneous sym type: (<any>)void
at JFreeChartExample.<init>(JFreeChartExample.java:32)
at JFreeChartExample.main(JFreeChartExample.java:45)
Java Result: 1

Line java:32 -plot.setDirection(Rotation.CLOCKWISE);

如果我打开代码并突出显示 setDirection,它会说The type of setDirection(Rotation) is erroneous

下面是demo的代码。

import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.util.Rotation;

public class JFreeChartExample extends JFrame {

    public JFreeChartExample(String frameTitle, String chartTitle) {
        super(frameTitle);
        //Creates a sample defaultPieDataset
        DefaultPieDataset defaultPieDataset = new DefaultPieDataset();
        defaultPieDataset.setValue("c/c++", 19);
        defaultPieDataset.setValue("java", 46);
        defaultPieDataset.setValue("php", 35);

        // based on the defaultPieDataset we create the chart
        JFreeChart pieChart = ChartFactory.createPieChart3D(chartTitle, defaultPieDataset, true, true, false);
        PiePlot plot = (PiePlot) pieChart.getPlot();
        plot.setStartAngle(290);
        plot.setDirection(Rotation.CLOCKWISE);
        plot.setForegroundAlpha(0.5f);

        // Adding chart into a chart panel
        ChartPanel chartPanel = new ChartPanel(pieChart);

        // setting default size
        chartPanel.setPreferredSize(new java.awt.Dimension(300, 200));

        // add to contentPane
        setContentPane(chartPanel);
    }

    public static void main(String[] args) {
        JFreeChartExample chart = new JFreeChartExample("Language Usage Statistics", "Which language are you Learning?");
        chart.pack();
        chart.setVisible(true);
    }
}

我已将 jcommon-1.018.jar 和 jfreechart-1.0.15.jar 库导入到我的项目中。

我注意到的是,如果我仅为这个演示创建一个完整的新项目,它可以正常工作,但是当我将它合并到我现有的项目中时,我收到了这个错误。

任何帮助,将不胜感激!

谢谢

当我导航到源

    public void setDirection(Rotation direction) {
    // <editor-fold defaultstate="collapsed" desc="Compiled Code">
    /* 0: new           #3                  // class java/lang/RuntimeException
     * 3: dup
     * 4: ldc           #4                  // String Uncompilable source code - cannot find symbol\n  symbol:   class Rotation\n  location: class org.jfree.chart.plot.PiePlot
     * 6: invokespecial #5                  // Method java/lang/RuntimeException."<init>":(Ljava/lang/String;)V
     * 9: athrow
     *  */
    // </editor-fold>
}
4

0 回答 0