一段Applet,为什么不能通过编译,提示
Applet8_Controller.java:15: 找不到符号
符号: 方法 moveLabel(int,int)
位置: 类 java.applet.Applet
applet8.moveLabel(me.getX(),me.getY());
^
1 错误
xxxxxxxxxxxxxxxxxxxximport java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Applet8_Controller extends Applet implements MouseMotionListener{
Applet applet8;
public void init(){
addMouseMotionListener(this);
setBackground(Color.red);
}
public void mouseMoved(MouseEvent me){
if(applet8==null){
applet8=(Applet8)getAppletContext().getApplet("applet8");
}applet8.moveLabel(me.getX(),me.getY());}
public void mouseDragged(MouseEvent me){}
}
Applet8_Controller.java:15: 找不到符号
符号: 方法 moveLabel(int,int)
位置: 类 java.applet.Applet
applet8.moveLabel(me.getX(),me.getY());
^
1 错误
xxxxxxxxxxxxxxxxxxxximport java.awt.*;
import java.applet.*;
import java.awt.event.*;
public class Applet8_Controller extends Applet implements MouseMotionListener{
Applet applet8;
public void init(){
addMouseMotionListener(this);
setBackground(Color.red);
}
public void mouseMoved(MouseEvent me){
if(applet8==null){
applet8=(Applet8)getAppletContext().getApplet("applet8");
}applet8.moveLabel(me.getX(),me.getY());}
public void mouseDragged(MouseEvent me){}
}
applet8=(Applet)getAppletContext().getApplet("applet8");然后 applet8好象没有moveLable这个方法不知道干什么的。
moveLabel
下面是API中的说明。move
@Deprecated
public void move(int x, int y)Deprecated. As of JDK version 1.1, replaced by setLocation(int, int).
--------------------------------------------------------------------------------setLocation
public void setLocation(Point p)Moves this component to a new location. The top-left corner of the new location is specified by point p. Point p is given in the parent's coordinate space. Parameters:
p - the point defining the top-left corner of the new location, given in the coordinate space of this component's parent
Since:
JDK1.1
See Also:
getLocation(), setBounds(int, int, int, int)
就是方法没有定义估计是写掉了
改成 Applet8 applet8;试试