javax.swing.JTree.addTreeExpansionListener()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中javax.swing.JTree.addTreeExpansionListener()方法的一些代码示例,展示了JTree.addTreeExpansionListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.addTreeExpansionListener()方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:addTreeExpansionListener

JTree.addTreeExpansionListener介绍

暂无

代码示例

代码示例来源:origin: checkstyle/checkstyle

/**
 * Initialise tree and treeTableModel class attributes.
 * @param treeTableModel Tree table model.
 * @param tree JTree component.
 */
public TreeTableModelAdapter(ParseTreeTableModel treeTableModel, JTree tree) {
  this.tree = tree;
  this.treeTableModel = treeTableModel;
  tree.addTreeExpansionListener(new UpdatingTreeExpansionListener());
  // Install a TreeModelListener that can update the table when
  // mTree changes. We use delayedFireTableDataChanged as we can
  // not be guaranteed the mTree will have finished processing
  // the event before us.
  treeTableModel.addTreeModelListener(new UpdatingTreeModelListener());
}

代码示例来源:origin: deathmarine/Luyten

TreeListener tl = new TreeListener();
tree.addMouseListener(tl);
tree.addTreeExpansionListener(new FurtherExpandingTreeExpansionListener());
tree.addKeyListener(new KeyAdapter() {

代码示例来源:origin: pentaho/mondrian

/**
 * Constructor
 *
 * @param tree The tree to track
 */
public JTreeUpdater(JTree tree) {
  this.tree = tree;
  this.tree.addTreeExpansionListener(this);
  this.tree.addTreeSelectionListener(this);
}

代码示例来源:origin: pentaho/mondrian

/**
 * Call this method whenever you update the tree and needs it reloaded
 */
public synchronized void update() {
  synchronized (this.tree) {
    this.tree.removeTreeExpansionListener(this);
    this.tree.removeTreeSelectionListener(this);
    ((DefaultTreeModel) this.tree.getModel()).reload();
    for (TreePath treePath : expandedTreePaths) {
      this.tree.expandPath(treePath);
    }
    this.tree.getSelectionModel().setSelectionPaths(selectedTreePaths);
    this.tree.addTreeExpansionListener(this);
    this.tree.addTreeSelectionListener(this);
  }
}

代码示例来源:origin: stackoverflow.com

m_tree.setCellRenderer(renderer);
m_tree.addTreeExpansionListener(new  DirExpansionListener());

代码示例来源:origin: edu.stanford.protege/jtreetable

public AbstractTreeTableModel(JTree tree) {
  this.tree = tree;
  tree.addTreeExpansionListener(new TreeExpansionListener(){
    @Override
    public void treeExpanded(TreeExpansionEvent event) {
      notifyTreeExpanded(event);
    }
    @Override
    public void treeCollapsed(TreeExpansionEvent event) {
      notifyTreeCollapsed(event);
    }
  });
}

代码示例来源:origin: ricardojlrufino/eclipse-cdt-standalone-astparser

public TreeTableModelAdapter(TreeTableModel treeTableModel, JTree tree) {
  this.tree = tree;
  this.treeTableModel = treeTableModel;
tree.addTreeExpansionListener(new TreeExpansionListener() {
  // Don't use fireTableRowsInserted() here; 
  // the selection model would get  updated twice. 
  public void treeExpanded(TreeExpansionEvent event) {  
   fireTableDataChanged(); 
  }
    public void treeCollapsed(TreeExpansionEvent event) {  
   fireTableDataChanged(); 
  }
});
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

public static void makeTreeAutoExpandable(final JTree tree, final int maxChildToExpand, final boolean dontExpandToLeafs) {
  tree.addTreeExpansionListener(new TreeExpansionListener() {
      boolean internalChange = false;
      public void treeCollapsed(TreeExpansionEvent event) {
      }
      public void treeExpanded(TreeExpansionEvent event) {
        if (internalChange || Boolean.TRUE.equals(tree.getClientProperty(PROP_EXPANSION_TRANSACTION))) { // NOI18N
          return;
        }
        // Auto expand more if the just expanded child has only one child
        TreePath path = event.getPath();
        JTree tree = (JTree) event.getSource();
        internalChange = true;
        autoExpand(tree, path, MAX_TREE_AUTOEXPAND_LINES, maxChildToExpand, dontExpandToLeafs);
        internalChange = false;
      }
    });
}

代码示例来源:origin: de.schlichtherle.truezip/truezip-file

/**
 * Creates a new {@code TFileTree} which traverses the given
 * {@link TFileTreeModel}.
 */
public TFileTree(TFileTreeModel model) {
  super(model);
  super.addTreeExpansionListener(controller);
  super.setCellRenderer(new TFileTreeCellRenderer(this));
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

private void hookTreeCollapsedExpanded() {
  treeTable.getTree().addTreeExpansionListener(new TreeExpansionListener() {
    public void treeCollapsed(TreeExpansionEvent event) {
      updateSB();
    }
    public void treeExpanded(TreeExpansionEvent event) {
      updateSB();
    }
    private void updateSB() {
      SwingUtilities.invokeLater(new Runnable() {
        public void run() { updateScrollBar(false); }
      });
    }
  });
}

代码示例来源:origin: org.activecomponents.jadex/jadex-commons-gui

/**
 *  Create a tree expansion handler for a given tree.
 */
public TreeExpansionHandler(JTree tree)
{
  this.tree	= tree;
  this.expanded	= new HashSet();
  tree.addTreeExpansionListener(this);
  tree.getModel().addTreeModelListener(this);
  List    tehs    = (List)tree.getClientProperty(TreeExpansionHandler.class);
  if(tehs==null)
  {
    tehs    = new ArrayList();
    tree.putClientProperty(TreeExpansionHandler.class, tehs);			
  }
  tehs.add(this);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

public TreeTableModelAdapter(JTree t, NodeTableModel ntm) {
  this.tree = t;
  this.nodeTableModel = ntm;
  Listener listener = new Listener();
tree.addTreeExpansionListener(listener);
tree.getModel().addTreeModelListener(listener);
  nodeTableModel.addTableModelListener(listener);
}

代码示例来源:origin: wildfly/wildfly-core

private JTree makeTree(ManagementModelNode root) {
  root.explore();
  JTree tree = new CommandBuilderTree(cliGuiCtx, new DefaultTreeModel(root));
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  tree.addTreeExpansionListener(new ManagementTreeExpansionListener((DefaultTreeModel) tree.getModel()));
  tree.addTreeSelectionListener(new ManagementTreeSelectionListener());
  tree.addMouseListener(new ManagementTreeMouseListener(tree));
  return tree;
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

public TreeTableModelAdapter(JTree t, NodeTableModel ntm) {
  this.tree = t;
  this.nodeTableModel = ntm;
  Listener listener = new Listener();
  tree.addTreeExpansionListener(listener);
  tree.getModel().addTreeModelListener(listener);
  nodeTableModel.addTableModelListener(listener);
}

代码示例来源:origin: org.wildfly.core/wildfly-cli

private JTree makeTree(ManagementModelNode root) {
  root.explore();
  JTree tree = new CommandBuilderTree(cliGuiCtx, new DefaultTreeModel(root));
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  tree.addTreeExpansionListener(new ManagementTreeExpansionListener((DefaultTreeModel) tree.getModel()));
  tree.addTreeSelectionListener(new ManagementTreeSelectionListener());
  tree.addMouseListener(new ManagementTreeMouseListener(tree));
  return tree;
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

public TreeTableModelAdapter(JTree t, NodeTableModel ntm) {
  this.tree = t;
  this.nodeTableModel = ntm;
  Listener listener = new Listener();
tree.addTreeExpansionListener(listener);
tree.getModel().addTreeModelListener(listener);
  nodeTableModel.addTableModelListener(listener);
}

代码示例来源:origin: org.apache.accumulo/examples-simple

public void init() throws TableNotFoundException {
 DefaultMutableTreeNode root = new DefaultMutableTreeNode(new NodeInfo(topPath, q.getData(topPath)));
 populate(root);
 populateChildren(root);
 
 treeModel = new DefaultTreeModel(root);
 tree = new JTree(treeModel);
 tree.addTreeExpansionListener(this);
 tree.addTreeSelectionListener(this);
 text = new JTextArea(getText(q.getData(topPath)));
 data = new JTextArea("");
 JScrollPane treePane = new JScrollPane(tree);
 JScrollPane textPane = new JScrollPane(text);
 dataPane = new JScrollPane(data);
 JSplitPane infoSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, textPane, dataPane);
 JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, treePane, infoSplitPane);
 mainSplitPane.setDividerLocation(300);
 infoSplitPane.setDividerLocation(150);
 getContentPane().add(mainSplitPane, BorderLayout.CENTER);
}

代码示例来源:origin: com.puppycrawl.tools/checkstyle

/**
 * Initialise tree and treeTableModel class attributes.
 * @param treeTableModel Tree table model.
 * @param tree JTree component.
 */
public TreeTableModelAdapter(ParseTreeTableModel treeTableModel, JTree tree) {
  this.tree = tree;
  this.treeTableModel = treeTableModel;
  tree.addTreeExpansionListener(new UpdatingTreeExpansionListener());
  // Install a TreeModelListener that can update the table when
  // mTree changes. We use delayedFireTableDataChanged as we can
  // not be guaranteed the mTree will have finished processing
  // the event before us.
  treeTableModel.addTreeModelListener(new UpdatingTreeModelListener());
}

代码示例来源:origin: jsettlers/settlers-remake

/**
 * Initialize the Tree with the filesystem
 */
private void initTree() {
  RootTreeNode root = new RootTreeNode(executorService);
  for (File f : File.listRoots()) {
    root.add(new FilesystemTreeNode(f));
  }
  model = new DefaultTreeModel(root);
  // to fire change event when the loading is finished
  root.setModel(model);
  tree = new JTree(model);
  tree.addTreeSelectionListener(selectionListener);
  tree.addTreeExpansionListener(expansionListener);
  tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  tree.expandRow(0);
  tree.setRootVisible(false);
  tree.setCellRenderer(new FileTreeCellRenderer());
}

代码示例来源:origin: org.xworker/xworker_core

public static void createTreeExpansionListeners(ActionContext actionContext){
  Thing self = (Thing) actionContext.get("self");
  JTree parent = (JTree) actionContext.get("parent");
  
  for(Thing child : self.getChilds()){
    TreeExpansionListener obj = (TreeExpansionListener) child.doAction("create", actionContext);
    if(obj != null){
      parent.addTreeExpansionListener(obj);
    }
  }
}

相关文章

JTree类方法