当前位置: 技术问答>java相关
继续问问题:)各位老鸟帮帮忙啊~~~`呵呵~在线等~
来源: 互联网 发布时间:2017-04-12
本文导语: 我想编个applet在屏幕上画个圆~圆的大小和位子由鼠标的点击和拖动来动态确定~我写的程序有错~如下: import java.awt.*; import java.awt.event.*; import java.applet.*; public class Exame1 extends Applet implements MouseAdapter,MouseMotionList...
我想编个applet在屏幕上画个圆~圆的大小和位子由鼠标的点击和拖动来动态确定~我写的程序有错~如下:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Exame1 extends Applet implements MouseAdapter,MouseMotionListener{
int mouseX1 = 0;
int mouseY1 = 0;
int mouseX2 = 0;
int mouseY2 = 0;
public void init(){
addMouseAdapter(this);
addMouseMotionListener(this);
}
public void start(){}
public void paint(Graphics g){
g.drawOval(mouseX1, mouseY1,((mouseX2)-(mouseX1)),((mouseY2)-(mouseY1)));
}
public void destroy(){
System.exit(0);
}
public void mousePressed(MouseEvent ev){
mouseX1 = ev.getX();
mouseY1 = ev.getY();
repaint();
}
public void mouseDragged(MouseEvent ev){
mouseX2 = ev.getX();
mouseY2 = ev.getY();
repaint();
}
}
编译时错误如下:
Exame1.java:4:interface expected here
public class Exame1 extends Applet implements MouseAdapter,MouseMotingListner{
Exame1.java:4:Exame1 shoud be declared abstract; it does not define mouseMoved(java.awt.event.MouseEvent)in Exame1
pulic class Exame1 extends Applet implements
^
MouseAdapter,MouseMotionListener{
Exame1.java:11:cannot resolve symbol
symbol : method addMouseAdapter(Exame1)
location : class Exame1
addMouseAdapter(this);
^
3 error
这3个错误~`帮我看看程序哪儿不对~~拜托~1
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Exame1 extends Applet implements MouseAdapter,MouseMotionListener{
int mouseX1 = 0;
int mouseY1 = 0;
int mouseX2 = 0;
int mouseY2 = 0;
public void init(){
addMouseAdapter(this);
addMouseMotionListener(this);
}
public void start(){}
public void paint(Graphics g){
g.drawOval(mouseX1, mouseY1,((mouseX2)-(mouseX1)),((mouseY2)-(mouseY1)));
}
public void destroy(){
System.exit(0);
}
public void mousePressed(MouseEvent ev){
mouseX1 = ev.getX();
mouseY1 = ev.getY();
repaint();
}
public void mouseDragged(MouseEvent ev){
mouseX2 = ev.getX();
mouseY2 = ev.getY();
repaint();
}
}
编译时错误如下:
Exame1.java:4:interface expected here
public class Exame1 extends Applet implements MouseAdapter,MouseMotingListner{
Exame1.java:4:Exame1 shoud be declared abstract; it does not define mouseMoved(java.awt.event.MouseEvent)in Exame1
pulic class Exame1 extends Applet implements
^
MouseAdapter,MouseMotionListener{
Exame1.java:11:cannot resolve symbol
symbol : method addMouseAdapter(Exame1)
location : class Exame1
addMouseAdapter(this);
^
3 error
这3个错误~`帮我看看程序哪儿不对~~拜托~1
|
需要重载mouseMoved()方法;
还有addMouseAdapter()方法有问题
还有addMouseAdapter()方法有问题
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。