给一个JPanel添加一个键盘事件!怎么添加
解决方案 »
- win -7 有没有像 jre-6u12-windows-i586-p.exe的软件,安装后,不用配环境变量,直接可运行?
- Java高手请进 传值与传地址 非诚勿扰……
- Swing和Swt那个跟具有长远的发展前景
- a=a+1;a+=1;a++
- 本人新到CSDN,希望大家多多支持!
- 问几个个低级的问题!送100分
- 请教一个读写文件的小问题
- PrintTest.java的目录是C:\javacode\com\szallcom\tools;C:\javacode\wf\common目录有SystemProperties.class;编译要求引入wf.common.S
- 文件上传
- 选择什么样的java编译器?
- 请问Iterator为什么没有排序呢?
- 请教关于javax.servlet.RequestDispatcher.forward(request, response)
public static void main(String[] args) {
new MyFrame();
} public MyFrame() {
super("hello");
this.setSize(300, 400);
this.setVisible(true);
this.setBounds(200,200,400,400);
JPanel jp = new JPanel();
jp.setSize(200,200);
jp.setBackground(Color.GREEN);
jp.addKeyListener(new KeyAdapter (){
public void keyPressed(KeyEvent ke) {
System.out.println("@@");
}
public void keykeyReleased(KeyEvent ke) {
System.out.println("@@");
}
});
jp.setFocusable(true);
this.getContentPane().add(jp);
}
}