How do I turn the Scroll Lock button on?

Category: java.awt, viewed: 1152 time(s).

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);
    }
}


Java Training

Sponsored Links