0
我有这段代码,它创建了一个简单的笑脸。我想用鼠标移动来移动脸部的眼睛。这里是代码如何在java中移动鼠标移动的形状
int a,b;
public void recieve(int x,int y)
{
a=x;
b=y;
System.out.println("xaxis"+a+"yaxis"+b);
}
@Override
public void paintComponent(Graphics g)
{
super.paintComponent(g);
System.out.println("x axis: "+a+" -- y axis: "+b);
g.drawArc(100, 50, 150, 150, 0, 360);
g.drawArc(125, 65, 40, 40, 0, 360);
g.drawArc(180, 65, 40, 40, 0, 360);
g.drawArc(165, 105, 15, 15, 60, 180);
g.fillOval(a-130, 70, 15, 15);
g.fillOval(b-185, 70, 15, 15);
}
这里的[一个例子(http://stackoverflow.com/questions/34981403/bufferedimage-not-being-cleared-before-each-rendering/35002727#35002727)你在找什么。 –