This example show you how to detect if the Scroll Lock key is in active mode. If you run the program you will get an output telling you that the Scroll Lock button is active or not active.
package org.kodejava.awt;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
public class ScrollLockState {
public static void main(String[] args) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
// Get the locking state of the Scroll Lock button. This method
// return boolean true value if it is "on".
boolean isOn = toolkit.getLockingKeyState(KeyEvent.VK_SCROLL_LOCK);
System.out.println("ScrollLock button is " + (isOn ? "on" : "off"));
}
}
Latest posts by Wayan (see all)
- How do I create a table with multiple header in iText 8? - March 16, 2024
- How do I add Image to a Table in iText 8? - March 11, 2024
- How do I downgrade Android SDK emulator version? - February 12, 2024