我最近制作了一个Netbeans项目,同时使用SVN。在控制台上,我看到了重复类错误:
java.lang.VerifyError: (class: pie/chart/explorer/PieChartExplorer, method: <init> signature: ()V) 构造函数必须调用super()或this()方法
无法找到主类:pie.chart.explorer.PieChartExplorer。程序将退出。
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");
}
}
}
}
我已经尝试过:
- 清理和重新构建项目
- 确保我在所有构造函数中都调用了super
如何解决?下载代码。
Pie
类的包?在注释掉actionPerformed
方法后(因为 Pie 类),你的代码已经成功地使用 javac-1.6.0_13 编译。 - Emre Yazici