当前位置: 技术问答>java相关
一个小问题~~`大家来看看咯~``
来源: 互联网 发布时间:2017-04-17
本文导语: 我在Applet上加了1个Canvas(画布);想在上面动态画些圆;我拿Applet做过~`可以在Applet上动态画圆;但Applet和Canvas都有paint()函数啊``~我该怎么弄??? 我的程序如下~:(有错) import java.awt.*; import java.awt.event.*; import...
我在Applet上加了1个Canvas(画布);想在上面动态画些圆;我拿Applet做过~`可以在Applet上动态画圆;但Applet和Canvas都有paint()函数啊``~我该怎么弄???
我的程序如下~:(有错)
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Exame4 extends Applet implements MouseListener,MouseMotionListener{
Choice c;
Canvas ca;
Panel p1,p2;
int mouseX1 = 0;
int mouseY1 = 0;
int mouseX2 = 0;
int mouseY2 = 0;
public void init(){
setLayout(new BorderLayout());
p1 = new Panel();
p2 = new Panel();
ca = new Canvas();
c = new Choice();
add("West",p1);
add("East",p2);
p1.add(ca);
p2.add(c);
addMouseListener(this);
addMouseMotionListener(this);
}
public void start(){
ca.paint(Graphics g){
g.drawOval(mouseX1, mouseY1,((mouseX2)-(mouseX1)),((mouseY2)-(mouseY1)));//我把canvas的paint()这样弄对吗????
}
}
public void paint(Graphics g){}
public void destroy(){
System.exit(0);
}
public void mousePressed(MouseEvent ev){
mouseX1 = ev.getX();
mouseY1 = ev.getY();
repaint();
}
public void mouseClicked(MouseEvent ev){}
public void mouseEntered(MouseEvent ev){}
public void mouseExited(MouseEvent ev){}
public void mouseReleased(MouseEvent ev){}
public void mouseDragged(MouseEvent ev){
mouseX2 = ev.getX();
mouseY2 = ev.getY();
repaint();
}
public void mouseMoved(MouseEvent ev){}
}
错误是:
Exame4.java:27:')'expected
ca.paint(Graphics g){
Exame4.java:29:';'expected
}
Exame4.java:27:cannot resolve symbol
symbol :variable Graphics
location:class Exame4
ca.paint(Graphics g){
我的程序如下~:(有错)
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class Exame4 extends Applet implements MouseListener,MouseMotionListener{
Choice c;
Canvas ca;
Panel p1,p2;
int mouseX1 = 0;
int mouseY1 = 0;
int mouseX2 = 0;
int mouseY2 = 0;
public void init(){
setLayout(new BorderLayout());
p1 = new Panel();
p2 = new Panel();
ca = new Canvas();
c = new Choice();
add("West",p1);
add("East",p2);
p1.add(ca);
p2.add(c);
addMouseListener(this);
addMouseMotionListener(this);
}
public void start(){
ca.paint(Graphics g){
g.drawOval(mouseX1, mouseY1,((mouseX2)-(mouseX1)),((mouseY2)-(mouseY1)));//我把canvas的paint()这样弄对吗????
}
}
public void paint(Graphics g){}
public void destroy(){
System.exit(0);
}
public void mousePressed(MouseEvent ev){
mouseX1 = ev.getX();
mouseY1 = ev.getY();
repaint();
}
public void mouseClicked(MouseEvent ev){}
public void mouseEntered(MouseEvent ev){}
public void mouseExited(MouseEvent ev){}
public void mouseReleased(MouseEvent ev){}
public void mouseDragged(MouseEvent ev){
mouseX2 = ev.getX();
mouseY2 = ev.getY();
repaint();
}
public void mouseMoved(MouseEvent ev){}
}
错误是:
Exame4.java:27:')'expected
ca.paint(Graphics g){
Exame4.java:29:';'expected
}
Exame4.java:27:cannot resolve symbol
symbol :variable Graphics
location:class Exame4
ca.paint(Graphics g){
|
在这里发贴,表示您接受了CSDN论坛的 用户行为准则。
请您对您的言行负责,并遵守中华人民共和国有关法律、法规,尊重网上道德。
请您对您的言行负责,并遵守中华人民共和国有关法律、法规,尊重网上道德。
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。