我是个新手,在MYECLIPE中老出现这样一个报错“Syntax error, insert ";" to complete Statement”,不知道到底是错在哪个地方。请

解决方案 »

  1.   

    Syntax error, insert ";" to complete Statement”,
    是你的代码少了 ; 号检查红颜色的代码
      

  2.   

    你的inset语句,语法可能有错
      

  3.   

    但我找不出错误的原因啊import java.awt.*;
    import java.awt.event.*;
    public class TwoListenInner {
    private Frame f;
    private TextField tf;
    public static void main(String args[]) {
    TwoListenInner that=new TwoListenInner();
    that.go(); 
      }   public void go() {
    f=new Frame("Two listeners example");
    f.add("North",new Label("Click and drag the mouse"));
    tf=new TextField(30);
    f.add("South",tf);
    f.addMouseMotionListener(new MouseMotionHandler());
            f.addMouseListener(new MouseEventHandler());
            f.setSize(300,300);
            f.setVisible(true);
      } 
      public class MouseMotionHandler extends MouseMotionAdapter { 
      public void mouseDragged(MouseEvent e){
      String s="Mouse dragging:X="+e.getX()+"Y="+e.getY();
      tf.setText(s);
        }
    }
      public class MouseEventHandler extends MouseAdapter {
      public void mouseEntered(MouseEvent e){
      String s="The mouse entered";
      tf.setText(s);
        }
    public void mouseExited(MouseEvent e){
    String s="The mouse left the building";
    tf.setText(s);
        }
      }
    }
      

  4.   

    我大概修改了一下,你看看,在我这里已经可以运行了。下次记得写frame的结束和关闭事件呀!import java.awt.*;
    import java.awt.event.*;
    public class TwoListenInner {
    private Frame f;
    private TextField tf;
    public static void main(String args[]) {
    TwoListenInner that=new TwoListenInner();
    that.go();
    }public void go() {
    f=new Frame("Two listeners example");
    f.add("North",new Label("Click and drag the mouse"));
    tf=new TextField(30);
    f.add("South",tf);
    f.addMouseMotionListener(new MouseMotionHandler());
    f.addMouseListener(new MouseEventHandler());
    f.setSize(300,300);
    f.setVisible(true);
    }
    public class MouseMotionHandler extends MouseMotionAdapter {
    public void mouseDragged(MouseEvent e){
    String s="Mouse dragging:X="+e.getX()+"Y="+e.getY();
    tf.setText(s);
        }
    }
    public class MouseEventHandler extends MouseAdapter {
    public void mouseEntered(MouseEvent e){
    String s="The mouse entered";
    tf.setText(s);
          }
    public void mouseExited(MouseEvent e){
    String s="The mouse left the building";
    tf.setText(s);
       }
     }
    }