I have a JTextArea that cannot be selected in a specific setting. However, in this parameter, the user can still use the space bar and return key. To place the space, I have the following code,
if (e.getKeyChar() == KeyEvent.VK_SPACE) {
editor.insert(" ", editor.getCaretPosition());
}
I have a problem with backspace. I tried this
if (e.getKeyChar() == KeyEvent.VK_BACK_SPACE) {
editor.insert("\b", editor.getCaretPosition());
}
It seems like a little space is added when backspace is pressed. It is not as much as space, and it is almost imperceptible when pressed once. However, this is definitely not reverse space. In the worst case, I will have to copy all the characters to the carriage position - 1 and add them to all the characters after the carriage position, but I do not like this solution.
source
share