我学的是第8版Java语言程序设计(基础篇),我画了一个圆,怎么让它上下左右移动啊?方法别太难,我怕看不懂~谢谢各位大神!!!
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame; public class YuanYiDong extends JFrame {
public void paint(Graphics g) {
int x = 230;
int y = 150;
int h=50;
int w=50;
g.setColor(Color.blue);
g.fillOval(x, y, w, h);
}
public static void main(String[] args) {
JFrame frame = new TestKeyEvent();
frame.setTitle("圆的移动");
frame.setLocation(300,100);
frame.setSize(500, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame; public class YuanYiDong extends JFrame {
public void paint(Graphics g) {
int x = 230;
int y = 150;
int h=50;
int w=50;
g.setColor(Color.blue);
g.fillOval(x, y, w, h);
}
public static void main(String[] args) {
JFrame frame = new TestKeyEvent();
frame.setTitle("圆的移动");
frame.setLocation(300,100);
frame.setSize(500, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}