程序编译没错就是运行后没有反应.实在是不知道该怎么做了.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class test extends JFrame{
JPanel pl;
public test()
{
pl=new JPanel();
this.setLayout(null);
pl.setBounds(50,50,60,60);
pl.setBackground(Color.red);
this.getContentPane().add(pl);
this.setTitle("练习");
this.addKeyListener(new KeyAdapter()
{
public void pl_keyPressed(KeyEvent e){
if(e.getKeyCode()==39){
System.out.println("213");
pl.setLocation(pl.getLocation().x,pl.getLocation().y+10);
}
}
});
}
public static void main(String arg[]){
test ts=new test();
ts.setBounds(200,100,300,300);
ts.show();
}
}
[此贴子已经被作者于2007-7-19 22:00:13编辑过]