标题:[求助]KeyAdapter类问题(在线等)
取消只看楼主
初心者1号
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2007-3-31
 问题点数:0 回复次数:1 
[求助]KeyAdapter类问题(在线等)

程序编译没错就是运行后没有反应.实在是不知道该怎么做了.
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编辑过]

搜索更多相关主题的帖子: KeyAdapter import awt java public 
2007-07-19 21:59
初心者1号
Rank: 1
等 级:新手上路
帖 子:42
专家分:0
注 册:2007-3-31
得分:0 
2楼的女侠说对了,把pl_去掉就可以了.
2007-07-21 23:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-156725-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.615074 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved