1 + ""
2 try { a=Integer.parseInt(note.getText())+1; } catch

解决方案 »

  1.   

    or:
    int to string : Integer.toString(123);2, the same as vcshcn(xx)
      

  2.   

    Integer.toSring() or Double.toSring()
      

  3.   

    public void AddMinus()
    这是构造函数没有返回值的
    去掉void写成public AddMinus()
    就可以了
      

  4.   

    把下面代码里的东西去掉note.setText("");抛异常的
    if(e.getActionCommand().equals("Add"))
    {
    × note.setText("");×
    int a;
    a=Integer.parseInt(note.getText())+1;
    String s=""+a;
    note.setText(s);
    }
    else if(e.getActionCommand().equals("Minus"))
    {
    × note.setText("");×
    int a;
    a=Integer.parseInt(note.getText())-1;
    String s=""+a;
    note.setText(s);
    }
      

  5.   

    改了一下,可以工作import java.awt.*;
    import java.awt.event.*;public class AddMinus extends WindowAdapter implements ActionListener {
        private Frame frm;
        private Panel pan1,pan2;
        private TextField note;
        private Button b1,b2,b3;    public AddMinus() {
            frm = new Frame("Add and Minus");
            frm.setLayout(new BorderLayout());
            pan1 = new Panel();
            pan2 = new Panel();
            pan1.setLayout(new FlowLayout());
            pan2.setLayout(new FlowLayout());
            b1 = new Button("Add");
            b1.addActionListener(this);
            b2 = new Button("Minus");
            b2.addActionListener(this);
            b3 = new Button("Exit");
            b3.addActionListener(this);
            note = new TextField();
            pan1.add(note);
            pan2.add(b1);
            pan2.add(b2);
            pan2.add(b3);
            frm.add(pan1, BorderLayout.CENTER);
            frm.add(pan2, BorderLayout.SOUTH);
            frm.setSize(400, 300);
            frm.addWindowListener(this);
            frm.pack();
            frm.show();
        }    public void WindowClosing(WindowEvent e) {
            System.exit(0);
        }    public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals("Add")) {
                //note.setText("");
                int a;
                try {
                    a = Integer.parseInt(note.getText()) + 1;
                } catch (NumberFormatException e1) {
                    a = 0;
                }
                String s = "" + a;
                note.setText(s);
            } else if (e.getActionCommand().equals("Minus")) {
                //note.setText("");
                int a;
                try {
                    a = Integer.parseInt(note.getText()) - 1;
                } catch (NumberFormatException e2) {
                    a = 0;
                }
                String s = "" + a;
                note.setText(s);
            } else
                System.exit(0);
        }    public static void main(String args[]) {
            AddMinus e = new AddMinus();
        }
    }
      

  6.   

    addWindowListener(
            new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });