repaint( )
//MouseEvents.javaimport java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class MouseEvents extends Applet implements MouseListener
{
String msg = "";
int mouseX = 0, mouseY = 0;
public void init() {
addMouseListener(this);
}
public void mouseClicked(MouseEvent me)
{
mouseX = 0;
mouseY = 10;
msg = "鼠标被单击了";
repaint();
}
public void mouseEntered(MouseEvent me)
{
mouseX = 0;
mouseY = 10;
msg = "鼠标进来了";
repaint();
}
public void mouseExited(MouseEvent me)
{
mouseX = 0;
mouseY = 10;
msg = "鼠标被移走了";
repaint();
}
public void mousePressed(MouseEvent me)
{
mouseX = me.getX();
mouseY = me.getY();
msg = "鼠标被按下了";
repaint();
}
public void mouseReleased(MouseEvent me)
{
mouseX = me.getX();
mouseY = me.getY();
msg = "鼠标被放开了";
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg, mouseX, mouseY);
}
public static void main(String arg[])
{
MouseEvents A = new MouseEvents();
}
}
请教一下repaint()是什么?