Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

24
LINES

< > BotCompany Repo | #1008647 // JTree with children made on demand [WORKS]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 3874K of libraries. Click here for Pure Java version (2232L/15K).

!7

import javax.swing.tree.*;

p-substance {
  DefaultMutableTreeNode rootNode = new("root");
  rootNode.add(new DefaultMutableTreeNode("dummy"));
  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) throws ExpandVetoException {
      DefaultMutableTreeNode node = cast e.getPath().getLastPathComponent();
      print("treeWillExpand, node=" + node.getUserObject());
      node.removeAllChildren();
      node.add(new DefaultMutableTreeNode(str(now())));
      ((DefaultTreeModel) tree.getModel()).nodeStructureChanged(node);
    }
  });
  
  showFrame(jscroll(tree));
}

Author comment

Began life as a copy of #1008646

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: #1008647
Snippet name: JTree with children made on demand [WORKS]
Eternal ID of this version: #1008647/18
Text MD5: 6f9e981f3d1102dcf62341e906d79bed
Transpilation MD5: 64b1a34ee8bc2fbea3b5890623c0ad18
Author: stefan
Category: javax / gui
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-05-26 18:03:58
Source code size: 816 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 590 / 1096
Version history: 17 change(s)
Referenced in: [show references]