KeyPressed event in java

后端 未结 3 1746
南笙
南笙 2021-01-03 04:34

I have just created a java tic-tac-toe game i would like to figure out how to run a method once the enter key is pressed during a certain condition an example is below...

3条回答
  •  隐瞒了意图╮
    2021-01-03 05:26

    Caveat - It's been a while since I did desktop applications, but the java.awt.Component class has an addKeyListener() method which you can use to register a class that implements KeyListener - is this what you are looking for?

提交回复
热议问题