import java.io.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
class Test1{
public static void main(String[] args){
Cilent c=new Cilent();
}
}
class Cilent implements KeyListener{
int x=10,y=10,cx=100,cy=100;
Cilent(){
Frame f=new Frame("Ball Client");
f.setSize(600,600);
Panel p=new Panel();
f.add(p);
f.addKeyListener(this);
f.addKeyListener(this);
f.setVisible(true);
}
public void paint(Graphics g){
g.setColor(Color.blue);
g.drawOval(x,y,10,10);
g.setColor(Color.red);
g.drawOval(cx,cy,10,10);
}
public void keyTyped(KeyEvent e){
}
public void keyReleased(KeyEvent e){
}
public void keyPressed(KeyEvent e){
if(e.getKeyCode()==KeyEvent.VK_LEFT && x<600){
x++;
}
if(e.getKeyCode()==KeyEvent.VK_RIGHT && x>0){
x--;
}
if(e.getKeyCode()==KeyEvent.VK_UP && y>0){
y--;
}
if(e.getKeyCode()==KeyEvent.VK_DOWN && y<600){
y++;
}
repaint();
}
}
谁能帮我看看上面这个程序为什么画不出来呢?