0
に私はプログラムを持っていないとき:JAVA:HKと実行プログラムの焦点
`
import java.awt.FlowLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Main {
public static void main(String[] args) {
JLabel time = new JLabel("10");
JLabel timer = new JLabel("Timer: ");
JFrame frame = new JFrame("Timer");
frame.setLayout(new FlowLayout());
frame.add(timer);
frame.add(time);
frame.pack();
frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
frame.setLocationByPlatform(true);
// Set's the window to be "always on top"
frame.setAlwaysOnTop(true);
frame.setVisible(true);
}
}
`
i "がVK_NUMPAD0" タイマーのようなキーボードのキーを押すべきカウントダウンを開始する。私はそれをカウントダウンするクラスを持っています。
私の質問は:フレームがでなく、キーボードのプッシュを聞くにはどうすればいいですか?にフォーカスがあります。それはちょうど上に横たわるだろうから。