有任何想法吗 ?第 66 行是一个大括号,你会在下面看到它,我在下面用 // 显示它。在 Eclipse 中,它不断出现错误,并且不知道如何摆脱它。有任何想法吗?谢谢!它是在动作监听器之后写的,我忘了关闭它吗?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class operation extends JFrame{
private JTextField monday;
private JTextField tuesday;
private JTextField wednesday;
private JTextField thursday;
private JTextField friday;
private JTextField saturday;
private JTextField sunday;
private JButton finalize;
public operation(){
super("Weekly Total Calculator");
setLayout(new FlowLayout());
monday = new JTextField("How much you spent Monday", 20);
monday.setFont(new Font("Ariel", Font.PLAIN, 14));
add(monday);
tuesday = new JTextField("How much you spent Tuesday", 20);
tuesday.setFont(new Font("Ariel", Font.PLAIN, 14));
add(tuesday);
wednesday = new JTextField("How much you spent Wednesday", 20);
wednesday.setFont(new Font("Ariel", Font.PLAIN, 14));
add(wednesday);
thursday = new JTextField("How much you spent Thursday", 20);
thursday.setFont(new Font("Ariel", Font.PLAIN, 14));
add(thursday);
friday = new JTextField("How much you spent Friday", 20);
friday.setFont(new Font("Ariel", Font.PLAIN, 14));
add(friday);
saturday = new JTextField("How much you spent Saturday", 20);
saturday.setFont(new Font("Ariel", Font.PLAIN, 14));
add(saturday);
sunday = new JTextField("How much you spent Sunday", 20);
sunday.setFont(new Font("Ariel", Font.PLAIN, 14));
add(sunday);
finalize = new JButton("Calculate!");
add(finalize);
finalize.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
double mon = Double.parseDouble(monday.getText());
double tues = Double.parseDouble(tuesday.getText());
double wed = Double.parseDouble(wednesday.getText());
double thurs = Double.parseDouble(thursday.getText());
double fri = Double.parseDouble(friday.getText());
double sat = Double.parseDouble(saturday.getText());
double sun = Double.parseDouble(sunday.getText());
private double sum = mon + tues + wed + thurs + fri + sat + sun;
JOptionPane.showMessageDialog(null, "Your total is " + sum + "!", "Total", JOptionPane.PLAIN_MESSAGE);
}
}
//THIS IS THE ERROR^
}
}
请帮忙!任何想法都会奏效。我真的不知道这笔交易是什么:(