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

16
LINES

< > BotCompany Repo | #1031107 // makeUneditableWithTextColor

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

Libraryless. Click here for Pure Java version (9617L/53K).

static <A extends JTextComponent> A makeUneditableWithTextColor(A a, Color color) {
  if (a != null) swing {
    a.setEditable(false);
    
    // prevent auto-scrolling when text is changed programmatically
    DefaultCaret caret = cast a.getCaret();
    caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    
    a.setDisabledTextColor(color);
  }
  ret a;
}

static <A extends JTextComponent> A makeUneditableWithTextColor(Color color, A a) {
  ret makeUneditableWithTextColor(a, color);
}

Author comment

Began life as a copy of #1031106

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031107
Snippet name: makeUneditableWithTextColor
Eternal ID of this version: #1031107/4
Text MD5: 6d7ca2e83eeabc393825333469412892
Transpilation MD5: fabb1087508cc04c2d2a77ff6dc92214
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-11-08 11:00:57
Source code size: 507 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 108 / 166
Version history: 3 change(s)
Referenced in: [show references]