I have a JTextArea and I want to disable blinking from it. I have tried to set focusable to false, but it doesn't seem to work. I also set editable to false and it doesn't work either. Any idea?
Update
getCaret().setVisible()
doesn't seem to have any effect, at least with the Metal and Windows 7 L&Fs.
Here's two suggestions that might be enough for you, depending on what your final requirements:
Set the caret color to the same color as the JTextField
background, effectively making it invisible.
myJTextField.setCaretColor(myJTextField.getBackground());
If you want to show the caret at a later time (say when the field gets focus), you could switch back to the original color (the documentation says passing a null
will do that) when your JTextField
gets focus.
Set the blink rate to 0 so even though the cursor will be visible, it won't be blinking.
myJTextField.getCaret().setBlinkRate(0);
It seems like you want to hide the caret (the |
cursor that indicates the current text insert position).
You can use JTextField.getCaret().setVisible(false);