-4

何か案は ?66 行目は中かっこです。下に表示されます。下に // を付けて表示します。日食では、エラーが発生し続け、それを取り除く方法をidkします。何か案は?ありがとう!アクション リスナーの後に書き込みます。閉じるのを忘れましたか?

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^

    }



}

助けてください!どんなアイデアでもうまくいきます。私は本当に契約が何であるか分かりません:(

4

4 に答える 4

7

メソッド呼び出し内で匿名オブジェクトを作成しています。最後にメソッド呼び出しを閉じてください。

finalize.addActionListener(new ActionListener(){
       public void actionPerformed(ActionEvent ae){
           // all your stuff
       }
}); // you were missing the ");"
于 2012-08-03T01:09:13.680 に答える
5

);問題は、 66 行目のブラケットの後に追加する必要があることだと思います。

于 2012-08-03T01:09:19.183 に答える
3

ない");"

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);

           }
    });
于 2012-08-03T01:10:26.173 に答える
1

で開いた括弧を閉じていませんfinalize.addActionListener(。また、セミコロンがありません。

于 2012-08-03T01:09:38.907 に答える