1 | static void textComponentDependButtons(final JTextComponent tc, L<? extends Component> buttons) { |
2 | for (Component c : buttons) |
3 | if (c instanceof JButton) { |
4 | final JButton b = cast c; |
5 | tc.addCaretListener(new CaretListener { |
6 | public void caretUpdate(CaretEvent e) { |
7 | b.setEnabled(tc.getSelectionEnd() > tc.getSelectionStart()); |
8 | } |
9 | }); |
10 | b.setEnabled(tc.getSelectionEnd() > tc.getSelectionStart()); |
11 | } |
12 | } |
Began life as a copy of #1004936
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1005049 |
Snippet name: | textComponentDependButtons |
Eternal ID of this version: | #1005049/1 |
Text MD5: | 9fcbe2830b7c6734859d239552455ab3 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-10-03 20:31:25 |
Source code size: | 462 bytes / 12 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 621 / 604 |
Referenced in: | [show references] |