gpt4 book ai didi

java - 方法必须调用 Netbeans 中的 super() 错误

转载 作者:搜寻专家 更新时间:2023-10-30 21:17:26 25 4
gpt4 key购买 nike

最近我制作了一个 Netbeans 项目,同时使用了 SVN。我看到重复的类错误,并且在控制台中显示

java.lang.VerifyError: (class: pie/chart/explorer/PieChartExplorer, method: <init> signature: ()V) Constructor must call super() or this()<br/>
Could not find the main class: pie.chart.explorer.PieChartExplorer. Program will exit.<br/>
Exception in thread "main" Java Result: 1

这是 PieChartExplorer.java:

package pie.chart.explorer;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class PieChartExplorer extends JFrame implements ActionListener {


JTextField one = new JTextField(10);
JTextField two = new JTextField(10);
JTextField three = new JTextField(10);
JButton sub = new JButton("Click to be amazed");


public PieChartExplorer() {
super("Pie Chart Explorer");
setSize(300,100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
FlowLayout flo = new FlowLayout();
setLayout(flo);
setVisible(true);
add(one);
add(two);
add(three);
sub.addActionListener(this);;
add(sub);

}

public static void main(String[] args) {
PieChartExplorer app = new PieChartExplorer();
}

@Override
public void actionPerformed(ActionEvent e) {
Object source = e.getSource();

if(source == sub) {
try {
Pie show = new Pie(Float.parseFloat(one.getText()),Float.parseFloat(two.getText()),Float.parseFloat(three.getText()));
} catch(Exception ex) {
JOptionPane.showMessageDialog(this, "Please check entered data");

}
}
}

}

我试过:

  1. 清理和重建项目
  2. 确保我在所有构造函数中都调用了 super

如何解决这个问题? Code for download .

最佳答案

我发现重命名包没有用,旧的包还在。

当我将一个包从另一个应用程序复制到当前应用程序时,我的问题就开始了,该应用程序已经有一个同名的包。我试图向包中添加一些缺少的类。在我这样做之后,错误开始了。

为了解决这个问题,我从目标网络应用程序中删除了整个包并进行了清理和构建。然后我将源包复制到目标应用程序中。没有错误。

关于java - 方法必须调用 Netbeans 中的 super() 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6560988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com