如何用java画一个圆,并且让它运动? 10
这是我的画圆程序,不知哪里错了,另外,如何让圆运动?packageOOAD_2nd;importjava.awt.*;publicclassOneAnt{publicvo...
这是我的画圆程序,不知哪里错了,另外,如何让圆运动?
package OOAD_2nd;
import java.awt.*;
public class OneAnt {
public void paint (Graphics g) {
int x = 100;
int y = 20;
int r = 10;
g.setColor (Color.blue);
// 从x,y位置处画一个实心的圆
g.fillOval (x , y, 2 * r, 2 * r);
}
public static void main(String[] args)
{
OneAnt oa=new OneAnt();
oa.paint(Graphics g);
}
} 展开
package OOAD_2nd;
import java.awt.*;
public class OneAnt {
public void paint (Graphics g) {
int x = 100;
int y = 20;
int r = 10;
g.setColor (Color.blue);
// 从x,y位置处画一个实心的圆
g.fillOval (x , y, 2 * r, 2 * r);
}
public static void main(String[] args)
{
OneAnt oa=new OneAnt();
oa.paint(Graphics g);
}
} 展开
1个回答
展开全部
静态圆:
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
public class OneAnt extends JFrame {
public void paint(Graphics g) {
int x = 100;
int y = 80;
int r = 50;
g.setColor(Color.blue);
// 从x,y位置处画一个实心的圆
g.fillOval(x, y, 2 * r, 2 * r);
}
public static void main(String[] args)
{
OneAnt oa=new OneAnt();
oa.setSize(500, 300);
oa.setVisible(true);
}
}
动态圆可以用线程来实现
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
public class OneAnt extends JFrame {
public void paint(Graphics g) {
int x = 100;
int y = 80;
int r = 50;
g.setColor(Color.blue);
// 从x,y位置处画一个实心的圆
g.fillOval(x, y, 2 * r, 2 * r);
}
public static void main(String[] args)
{
OneAnt oa=new OneAnt();
oa.setSize(500, 300);
oa.setVisible(true);
}
}
动态圆可以用线程来实现
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询