老是出现报错!

marketduan 2006-04-15 11:52:20
我是个新手,在MYECLIPE中老出现这样一个报错“Syntax error, insert ";" to complete Statement”,不知道到底是错在哪个地方。请
...全文
127 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
btb368 2006-04-15
  • 打赏
  • 举报
回复
是你某行少了个分号的原因。双击错误,然后光标会自动在该行的。
Camelh 2006-04-15
  • 打赏
  • 举报
回复
你的inset语句,语法可能有错
interpb 2006-04-15
  • 打赏
  • 举报
回复
Syntax error, insert ";" to complete Statement”,


是你的代码少了 ; 号

检查红颜色的代码
ewalker 2006-04-15
  • 打赏
  • 举报
回复
我大概修改了一下,你看看,在我这里已经可以运行了。下次记得写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);
}
}
}
marketduan 2006-04-15
  • 打赏
  • 举报
回复
但我找不出错误的原因啊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);
    }
  }
}

62,628

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧