Libraryless. Click here for Pure Java version (10679L/59K).
1 | static bool setTextKeepCaret(S text, JTextComponent c) { |
2 | if (c == null) false; |
3 | ret swing(-> { |
4 | int caret = c.getCaretPosition(); |
5 | if (eq(c.getText(), text)) false; |
6 | c.setText(text); |
7 | setCaretPosition(c, caret); |
8 | true; |
9 | }); |
10 | } |
11 | |
12 | sbool setTextKeepCaret(JTextComponent c, S text) { |
13 | ret setTextKeepCaret(text, c); |
14 | } |
Began life as a copy of #1015604
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016439 |
Snippet name: | setTextKeepCaret - setText and try to keep caret position |
Eternal ID of this version: | #1016439/5 |
Text MD5: | e8a67c6633318fc94bf381a1ba001074 |
Transpilation MD5: | d449888b75a57102986f7a5393b030be |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2023-04-05 16:43:15 |
Source code size: | 344 bytes / 14 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 428 / 554 |
Version history: | 4 change(s) |
Referenced in: | [show references] |