static A visibleCaretOnDisabledTextArea(A textArea) { if (textArea != null) swing { textArea.setEnabled(false); textArea.getCaret().setVisible(true); textArea.getCaret().setSelectionVisible(true); textArea.addFocusListener(new FocusListener { @Override public void focusGained(FocusEvent e) { textArea.getCaret().setVisible(true); textArea.getCaret().setSelectionVisible(true); } @Override public void focusLost(FocusEvent e) { textArea.getCaret().setSelectionVisible(true); } }); } ret textArea; }