简体   繁体   中英

Some Questions about KeyEvent

I was just playing around with KeyListeners, and I noticed that on most tutorials on most websites, It requires use of a JTextArea which is good for typing stuff in, but what about when you want to make, a game for instance. How would you use KeyListeners for that? Sorry in advance if the question is a little vague.

This is indeed a very vague question. Deserves a vague answer.

You can add your keylistener to a JPanel in which your game runs. Example code here: http://zetcode.com/tutorials/javagamestutorial/movingsprites/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM