1 | import javax.swing.tree.*; |
2 | |
3 | // dummy text you can use as a temporary child for a lazy-filled node |
4 | sS jDynamicTree_v1_dummy = "<dummy>"; |
5 | |
6 | // updateChildren: func(DefaultMutableTreeNode) -> bool |
7 | // (true=there was a change) |
8 | static JTree jDynamicTree_v1(final DefaultMutableTreeNode rootNode, final F1<DefaultMutableTreeNode, Bool> updateChildren) { |
9 | ret swing(func -> JTree { |
10 | final JTree tree = new JTree(rootNode); |
11 | tree.setShowsRootHandles(true); |
12 | tree.collapseRow(0); |
13 | |
14 | tree.addTreeWillExpandListener(new TreeWillExpandListener { |
15 | public void treeWillCollapse(TreeExpansionEvent e) {} |
16 | public void treeWillExpand(TreeExpansionEvent e) { |
17 | DefaultMutableTreeNode node = cast e.getPath().getLastPathComponent(); |
18 | if (isTrue(pcallF(updateChildren, node))) |
19 | ((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node); |
20 | } |
21 | }); |
22 | |
23 | ret tree; |
24 | }); |
25 | } |
Began life as a copy of #1008647
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1008652 |
Snippet name: | jDynamicTree_v1 - JTree with children made on demand |
Eternal ID of this version: | #1008652/10 |
Text MD5: | fb4aa358c6b1e5e49e282d3732679dbf |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-06-03 13:46:21 |
Source code size: | 938 bytes / 25 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 565 / 585 |
Version history: | 9 change(s) |
Referenced in: | [show references] |