import javax.swing.tree.*; // dummy text you can use as a temporary child for a lazy-filled node sS jDynamicTree_v1_dummy = "<dummy>"; // updateChildren: func(DefaultMutableTreeNode) -> bool // (true=there was a change) static JTree jDynamicTree_v1(final DefaultMutableTreeNode rootNode, final F1<DefaultMutableTreeNode, Bool> updateChildren) { ret swing(func -> JTree { final JTree tree = new JTree(rootNode); tree.setShowsRootHandles(true); tree.collapseRow(0); tree.addTreeWillExpandListener(new TreeWillExpandListener { public void treeWillCollapse(TreeExpansionEvent e) {} public void treeWillExpand(TreeExpansionEvent e) { DefaultMutableTreeNode node = cast e.getPath().getLastPathComponent(); if (isTrue(pcallF(updateChildren, node))) ((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node); } }); ret tree; }); }
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: | 563 / 582 |
Version history: | 9 change(s) |
Referenced in: | [show references] |