1
我正在运行一个程序并有一个线程类instanciated称为minusstop。它可以工作,但现在基本上需要等待它,而程序的其余部分正在运行。如何等待“减号”键输入
package dimensionbot;
import java.awt.event.KeyEvent;
public class stopthread extends Thread {
public stopthread(){
System.out.println("Instanciated the stopthread class.");
}
public void keyevent(KeyEvent e) {
System.out.println("Got a key event.");
if (e.getKeyCode() == KeyEvent.VK_MINUS) {
System.exit(MIN_PRIORITY);
System.out.println("Got minus key pressed, shutting down system");
}
}
}
这是当按下减号它不会给我一个消息,说按钮被按下。
谢谢你的提示,但是,这并不使应用程序停止,它只是打印消息。任何想法? –