How do I turn the Scroll Lock button on?

The program below show you how to turn the scroll lock button on programatically. Setting the locking state to Boolean.TRUE activate the scroll lock.

package org.kodejava.example.awt;

import java.awt.*;
import java.awt.event.KeyEvent;

public class TurnScrollLockOn {
    public static void main(String[] args) {
        //
        // Gets the default toolkit.
        //
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        
        //
        // Update the locking state for scroll lock button to true
        // will turn the scroll lock on.
        //
        toolkit.setLockingKeyState(KeyEvent.VK_SCROLL_LOCK, Boolean.TRUE);
    }
}

Wayan

Programmer, runner, recreational diver, live in the island of Bali, Indonesia. Mostly programming in Java, creating web based application with Spring Framework, Hibernate / JPA.

Leave a Reply