java 按键消息监听器用法,Java命令行中的键监听器
Most demo showing keyevent in Swing, what is the equivalent in commandline?
解決方案
Swing is different from a command line environment in the sense that you have no events in a console window. A standard GUI deals with objects and events. A console has no such equivalent notion.
What you do have is a standard input (as well as a standard output), which you can read from. See this question on how to read a single char from console (without waiting for a newline) - or rather, on how this isn't very easy to do in Java.
Of course, you can always do the reading asynchronously on a separate thread. i.e. the main thread will keep doing stuff, with a listener thread waiting on the I/O blocking call. But this can only be implemented and handled on the application level.
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的java 按键消息监听器用法,Java命令行中的键监听器的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 虚拟dom原理是什么
- 下一篇: java美元兑换,(Java实现) 美元