java的applet小程序在鼠标点击处画圆 15
java的applet小程序在鼠标点击处画圆,怎么能让每次画的圆都保留啊下面是我的程序,应该怎么改,请指教!多谢了!importjava.awt.*;importjava...
java的applet小程序在鼠标点击处画圆,怎么能让每次画的圆都保留啊
下面是我的程序,应该怎么改,请指教!多谢了!
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class DrawOval extends Applet implements
MouseListener,MouseMotionListener{
int x,y;
public void init(){
this.addMouseListener(this);
this.addMouseMotionListener(this);
}
public void paint(Graphics g){
float a,b,c;
a=(float)Math.random();
b=(float)Math.random();
c=(float)Math.random();
g.setColor(new Color(a,b,c));
g.fillOval(x,y,10,10);
}
public void mouseClicked(MouseEvent e){
}
public void mouseEntered(MouseEvent e){
}
public void mouseExited(MouseEvent e){
}
public void mousePressed(MouseEvent e){
}
public void mouseReleased(MouseEvent e){
}
public void mouseDragged(MouseEvent e){
x=e.getX();
y=e.getY();
repaint();
}
public void mouseMoved(MouseEvent e){
}
}
回aoswce:那样的话就编译错误了啊... 展开
下面是我的程序,应该怎么改,请指教!多谢了!
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class DrawOval extends Applet implements
MouseListener,MouseMotionListener{
int x,y;
public void init(){
this.addMouseListener(this);
this.addMouseMotionListener(this);
}
public void paint(Graphics g){
float a,b,c;
a=(float)Math.random();
b=(float)Math.random();
c=(float)Math.random();
g.setColor(new Color(a,b,c));
g.fillOval(x,y,10,10);
}
public void mouseClicked(MouseEvent e){
}
public void mouseEntered(MouseEvent e){
}
public void mouseExited(MouseEvent e){
}
public void mousePressed(MouseEvent e){
}
public void mouseReleased(MouseEvent e){
}
public void mouseDragged(MouseEvent e){
x=e.getX();
y=e.getY();
repaint();
}
public void mouseMoved(MouseEvent e){
}
}
回aoswce:那样的话就编译错误了啊... 展开
1个回答
展开全部
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class DrawOval extends Applet implements
MouseListener,MouseMotionListener{
int x,y;
public void init(){
this.addMouseListener(this);
this.addMouseMotionListener(this);
}
public void paint(Graphics g){
float a,b,c;
a=(float)Math.random();
b=(float)Math.random();
c=(float)Math.random();
g.setColor(new Color(a,b,c));
g.fillOval(x,y,10,10);
}
public void mouseClicked(MouseEvent e){
}
public void mouseEntered(MouseEvent e){
}
public void mouseExited(MouseEvent e){
}
public void mousePressed(MouseEvent e){
}
public void mouseReleased(MouseEvent e){
}
public void mouseDragged(MouseEvent e){
x=e.getX();
y=e.getY();
paint(); //这里不要那个了,你试试看。。
}
public void mouseMoved(MouseEvent e){
}
}
import java.awt.event.*;
import java.applet.*;
public class DrawOval extends Applet implements
MouseListener,MouseMotionListener{
int x,y;
public void init(){
this.addMouseListener(this);
this.addMouseMotionListener(this);
}
public void paint(Graphics g){
float a,b,c;
a=(float)Math.random();
b=(float)Math.random();
c=(float)Math.random();
g.setColor(new Color(a,b,c));
g.fillOval(x,y,10,10);
}
public void mouseClicked(MouseEvent e){
}
public void mouseEntered(MouseEvent e){
}
public void mouseExited(MouseEvent e){
}
public void mousePressed(MouseEvent e){
}
public void mouseReleased(MouseEvent e){
}
public void mouseDragged(MouseEvent e){
x=e.getX();
y=e.getY();
paint(); //这里不要那个了,你试试看。。
}
public void mouseMoved(MouseEvent e){
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询