1 | static void listDependButtons(final JList list, fL<? extends Component> buttons) swing { |
2 | for (Component c : buttons) |
3 | if (c instanceof JButton) { |
4 | final JButton b = cast c; |
5 | list.addListSelectionListener(new ListSelectionListener { |
6 | public void valueChanged(ListSelectionEvent e) { |
7 | b.setEnabled(list.getSelectedIndex() >= 0); |
8 | } |
9 | }); |
10 | b.setEnabled(list.getSelectedIndex() >= 0); |
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: | #1005360 |
Snippet name: | listDependButtons - enable buttons when an item is selected in a JList |
Eternal ID of this version: | #1005360/4 |
Text MD5: | 200399d5b202082dc9e920ae55fa82a7 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-05-29 14:11:29 |
Source code size: | 446 bytes / 12 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 492 / 518 |
Version history: | 3 change(s) |
Referenced in: | [show references] |