Libraryless. Click here for Pure Java version (10679L/59K).
static bool setTextKeepCaret(S text, JTextComponent c) { if (c == null) false; ret swing(-> { int caret = c.getCaretPosition(); if (eq(c.getText(), text)) false; c.setText(text); setCaretPosition(c, caret); true; }); } sbool setTextKeepCaret(JTextComponent c, S text) { ret setTextKeepCaret(text, c); }
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: | 701 / 870 |
| Version history: | 4 change(s) |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |