I have the program:
`
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);
}
}
`
When i push a key on the keyboard like "VK_NUMPAD0" the timer should start count down. I have a class that make it count down.
My Question is: How can I listen to the keyboard push when the frame is not in focus. Since it will just be laying on the top.