为什么不能重画啊.
import java.awt.*;import javax.swing.*;
import java.awt.event.*;
public class F extends JFrame
{
public int chx=100, chy=100, xori=100,yori=100;
F()
{
Container fr=getContentPane();
setBackground(Color.red);
setSize(200,200);
addMouseMotionListener(new MouseMotionAdapter()
{
public void mouseMoved(MouseEvent me)
{
xori=chx;
yori=chy;
chx=me.getX();
chy=me.getY();
repaint();
}
}
);
setVisible(true);
}
public void paint(Graphics g)
{
g.drawLine(chx,chy-10,chx,chy+10);
g.drawLine(chx-10,chy,chx+10,chy);
g.setPaintMode();
}
public static void main(String args[])
{
new F();
}
}
这个为什么不能实现重绘?而且背景颜色也不对.好像还有截图似的.把桌面的东西都放到背景上了.