Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1034642 // visibleCaretOnDisabledTextArea - shows caret but not selection...

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (5171L/28K).

static <A extends JTextArea> 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;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034642
Snippet name: visibleCaretOnDisabledTextArea - shows caret but not selection...
Eternal ID of this version: #1034642/3
Text MD5: bcfdbfa4e0a625bb252fde5f298ab03d
Transpilation MD5: b18c3fd7e18450a128ecd4a6be6a8935
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-28 12:28:17
Source code size: 654 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 63 / 102
Version history: 2 change(s)
Referenced in: [show references]