class ClassCanvas extends Canvas{
private int keyboard_key = 0;
protected void paint(Graphics g){
//Never mind the drawing, essence is that keyRepeated isn't working!
g.drawString(""+keyboard_key,0,0,Graphics.TOP|Graphics.LEFT);
}
protected void keyRepeated(int keyCode) {
keyboard_key = keyCode;
}
}
我编译了这个,并且paint总是绘制0.就像keyRepeated甚至没有被执行一样。
我测试了“hasRepeatEvents()”并且它说“是”,那么为什么keyRepeated不起作用?
我想出了可能发生的事情。
keyPressed和keyReleased工作,但keyRepeated不是
其他信息: