//实现画笔功能
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.applet.*;
public class NumSecond_3 extends Applet implements MouseMotionListener
{
int width,height;
Image backBuffer;
Graphics backg;
int x,y;
public void init()
{
width=getSize().width;
height=getSize().height;
backBuffer=createImage(width,height);
backg=backBuffer.getGraphics();
backg.setColor(Color.black);
backg.fillRect(0,0,width,height);
this.setBackground(Color.black); //
backg.setColor(Color.white);
this.addMouseMotionListener(this);
}
public void update(Graphics g) //太离奇了,有时候,update要改成paint,有时候又要运行过后改回来就有效果。有时候网页上没
//没效果,而用applewviewer则有,请各位帮小弟看下
{
//g.setColor(Color.white);
g.setXORMode(Color.white);
g.fillOval(x,y,8,8);
}
public void mouseDragged(MouseEvent m){
x=m.getX();
y=m.getY();
repaint();
}
public void mouseMoved(MouseEvent m)
{
}
}
[求助]paint和update的离奇问题