Topic: KeyListenerDemo |
Print this page |
1.KeyListenerDemo | Copy to clipboard |
Posted by: zenghua2010 Posted on: 2005-12-11 23:29 import java.awt.*; import java.awt.event.*; class KeyListenerDemo extends Frame implements KeyListener{ KeyListenerDemo(String title){ super(title); addKeyListener(this); setSize(100,100); setVisible(true); } public void KeyPressed(KeyEvent e){ System.out.println("Key pressed: virtual key code="+ e.getKeyCode()); } public void KeyReleased(KeyEvent e){ System.out.println("Key released: virtual key code="+ e.getKeyCode()); } public void KeyTyped(KeyEvent e){ System.out.println("Key typed: character="+e.getKeyChar()); } public static void main(String args[]){ new KeyListenerDemo("Key Listener Demo"); } } |
2.Re:KeyListenerDemo [Re: zenghua2010] | Copy to clipboard |
Posted by: ranchgirl Posted on: 2005-12-12 00:47 Sorry, your code is not even compilable, why do you put here???? No question, no statement, why?? keyTyped() etc. methods need to start with a lower case letter. That is also Java coding convention. Thanks! |
3.Re:KeyListenerDemo [Re: zenghua2010] | Copy to clipboard |
Posted by: zenghua2010 Posted on: 2005-12-12 12:26 朋友,谢了!我感悟过来了,原来我编程时把这搞错了,太大意了。不好意思 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |