I have a program that uses JTextArea. When I set keyboard focus in the JTextArea in the GUI and then hold down, say, the 'E' key, only one letter 'E' appears in the area. If I want further 'E' letters, I have to release the button and press it again.
Is there a way to change this, so that, by holding the 'E' key on my keyboard, 'E' letters keep appearing until I release the key, as I am used to with most software? I'm using the OSX platform.
Example program:
import java.awt.*;
import javax.swing.*;
public class PressAndHold {
private JFrame frame = new JFrame();
private JTextArea textArea = new JTextArea();
public PressAndHold() {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400, 400);
frame.setLayout(new GridLayout());
frame.add(textArea);
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new PressAndHold();
}
});
}
}