static void listDependButtons(final JList list, fL<? extends Component> buttons) swing { for (Component c : buttons) if (c instanceof JButton) { final JButton b = cast c; list.addListSelectionListener(new ListSelectionListener { public void valueChanged(ListSelectionEvent e) { b.setEnabled(list.getSelectedIndex() >= 0); } }); b.setEnabled(list.getSelectedIndex() >= 0); } }
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: | 736 / 790 |
| Version history: | 3 change(s) |
| Referenced in: | #1005361 - listDependButton - enable button when an item is selected in a JList #1005669 - imageSelectionDepend - enable button when ImageSurface has a selection #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1015283 - onSelectionChanged - for JList |