Store in a text editor if it is not editable

I am using java and I am trying to do JTextAreathat which is not editable but still has a caret in the field. In other words, a text area that does not display the characters entered by the user, but still has a blinking caret (i.e. focus).

I am honestly a dead end on this issue. I tried dumping with setEditable, but this is not a way to save the caret. I also tried to delete the character that the user enters as soon as he types it, but I can not stop him blinking on the screen.

+6
source share
2 answers

I think the following will help you:

textArea.getCaret().setVisible(true);

or

textArea.getCaret().setSelectionVisible(true);
+10
source

textArea.getCaret().setVisible(true);

, TextArea EditorPane , , - , , .

, , , , .

text.addFocusListener(new FocusAdapter() {
  @Override
  public void focusGained(FocusEvent e) {
    text.getCaret().setVisible(true); // show the caret anyway
  }
});
+3

All Articles