当前位置: 首页>>代码示例>>Java>>正文


Java JTree.getSelectionPath方法代码示例

本文整理汇总了Java中javax.swing.JTree.getSelectionPath方法的典型用法代码示例。如果您正苦于以下问题:Java JTree.getSelectionPath方法的具体用法?Java JTree.getSelectionPath怎么用?Java JTree.getSelectionPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTree的用法示例。


在下文中一共展示了JTree.getSelectionPath方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: keyPressed

import javax.swing.JTree; //导入方法依赖的package包/类
public void keyPressed(KeyEvent e) {
    if (e.getKeyChar() == ' ') {
        JTree tree = (JTree) e.getSource();
        TreePath path = tree.getSelectionPath();
        if( null == path )
            return;

        Node node = Visualizer.findNode( path.getLastPathComponent() );
        if( null == node )
            return;
        
        boolean isSelected = settings.isNodeVisible( node );
        settings.setNodeVisible( node, !isSelected );
        tree.repaint();
        
        e.consume();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CheckListener.java

示例2: sortTree

import javax.swing.JTree; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
public static void sortTree(PnlGuiConfig pnlGuiConfig, DefaultMutableTreeNode root, JTree treeTypes) {
	if (root != null) {
		Enumeration e = root.depthFirstEnumeration();
		while (e.hasMoreElements()) {
			DefaultMutableTreeNode node = (DefaultMutableTreeNode) e.nextElement();
			if (!node.isLeaf()) {
				sort(node);   //selection sort
			}
		}
		
		//Atualizando a arvore
		if (updateTree) {
			TreePath treePath = treeTypes.getSelectionPath();
			DefaultTreeModel model = (DefaultTreeModel) treeTypes.getModel();
			model.reload();
			treeTypes.setSelectionPath(treePath);
			updateTree = false;
		}

		pnlGuiConfig.getPnlFieldCondition().ckDynamicClick();
	}
}
 
开发者ID:adelbs,项目名称:ISO8583,代码行数:24,代码来源:SortTreeHelper.java

示例3: keyReleased

import javax.swing.JTree; //导入方法依赖的package包/类
@Override
    public void keyReleased(KeyEvent e) {
        int keyCode = e.getKeyCode();
        if (keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN) {
            JTree tree = (JTree) e.getSource();
            int row = tree.getSelectionRows()[0];
            TreePath path = tree.getSelectionPath();
            if (path != null) {
                CheckNode node = (CheckNode) path.getLastPathComponent();

                Object o = node.getUserObject();
                if (o instanceof TreeElement) {
                    o = ((TreeElement) o).getUserObject();
                    if (o instanceof RefactoringElement) {
                        openDiff(node);
                    }
//                    else if (o instanceof FileObject) {
//                        tree.expandPath(path);
//                        TreePath pathForRow = tree.getPathForRow(row + 1);
//                        CheckNode lastPathComponent = (CheckNode) pathForRow.getLastPathComponent();
//                        Object userObject = lastPathComponent.getUserObject();
//                        if (userObject instanceof TreeElement) {
//                            Object refElement = ((TreeElement) userObject).getUserObject();
//                            if (refElement instanceof RefactoringElement) {
//                                openDiff(lastPathComponent);
//                            }
//                        }
//                    }
                }
            }
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:CheckNodeListener.java

示例4: keyPressed

import javax.swing.JTree; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
    if (e.getKeyChar() == ' ') {
        JTree tree = (JTree) e.getSource();
        TreePath path = tree.getSelectionPath();
        if (path != null) {
            CheckNode node = (CheckNode) path.getLastPathComponent();
            node.setSelected(!node.isSelected());
            tree.repaint();
            e.consume();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:CheckNodeListener.java

示例5: keyPressed

import javax.swing.JTree; //导入方法依赖的package包/类
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {

        if ( e.getSource() instanceof JTree ) {
            JTree tree = (JTree) e.getSource();
            TreePath path = tree.getSelectionPath();

            if ( toggle( path )) {
                e.consume();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:HintsPanelLogic.java

示例6: keyPressed

import javax.swing.JTree; //导入方法依赖的package包/类
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_SPACE ) {
        
        if ( e.getSource() instanceof JTree ) {
            JTree tree = (JTree) e.getSource();
            TreePath path = tree.getSelectionPath();

            if ( toggle( path )) {
                e.consume();
                repaint(); //XXX
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:CheckTreeView.java

示例7: keyPressed

import javax.swing.JTree; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_SPACE) {

        if ( e.getSource() instanceof JTree ) {
            JTree tree = (JTree) e.getSource();
            TreePath path = tree.getSelectionPath();

            if ( toggle( path )) {
                e.consume();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:HintsPanelLogic.java

示例8: keyPressed

import javax.swing.JTree; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
    int keyCode = e.getKeyCode();
    if (keyCode == KeyEvent.VK_SPACE) {
        JTree tree = (JTree) e.getSource();
        TreePath path = tree.getSelectionPath();
        if (path != null) {
            FileNode node = (FileNode) path.getLastPathComponent();
            node.setSelected(!node.isSelected());
            tree.repaint();
            e.consume();
        }
    } 
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:RevertDeletedAction.java

示例9: keyPressed

import javax.swing.JTree; //导入方法依赖的package包/类
@Override
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_SPACE || e.getKeyCode() == KeyEvent.VK_ENTER ) {

        if ( e.getSource() instanceof JTree ) {
            JTree tree = (JTree) e.getSource();
            TreePath path = tree.getSelectionPath();

            if ( toggle( path )) {
                e.consume();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:HintsPanelLogic.java

示例10: keyPressed

import javax.swing.JTree; //导入方法依赖的package包/类
public void keyPressed(KeyEvent e) {
    if (e.getKeyCode() == KeyEvent.VK_SPACE || e.getKeyCode() == KeyEvent.VK_ENTER ) {

        if ( e.getSource() instanceof JTree ) {
            JTree tree = (JTree) e.getSource();
            TreePath path = tree.getSelectionPath();

            if ( toggle( path )) {
                e.consume();
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:FmtSpaces.java

示例11: createTransferable

import javax.swing.JTree; //导入方法依赖的package包/类
@Override
public Transferable createTransferable(JComponent c) {
	JTree tree = (JTree) c;
	TreePath selectionPath = tree.getSelectionPath();
	Object lastPathComponent = selectionPath.getLastPathComponent();

	Transferable t = null;
	if (lastPathComponent instanceof ValueSourceTreeNode) {
		t = (ValueSourceTreeNode) lastPathComponent;
	} else if (lastPathComponent instanceof RangeAxisConfigTreeNode) {
		t = (RangeAxisConfigTreeNode) lastPathComponent;
	}
	return t;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:15,代码来源:PlotConfigurationTreeTransferHandler.java

示例12: isSelectedPathNode

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * Node == The thing that can be expanded Point == An object in the tree
 *
 * @param tree JTree Tree
 * @param data ArrayList Object Data
 * @return Boolean
 */
public static boolean isSelectedPathNode(JTree tree, ArrayList<Object> data) {
    TreePath tp = tree.getSelectionPath();
    Object object = null;
    String path = "";
    try {
        path = getPathOfTreePath(tp);
    } catch (Exception ex) {
        object = null;
    }
    return (tp != null) && (object == null);
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:19,代码来源:JTreeUtils.java

示例13: getSelectionPath

import javax.swing.JTree; //导入方法依赖的package包/类
private TreePath getSelectionPath() {
    JTree tree = getSelectedTree();
    if (tree != null) {
        return tree.getSelectionPath();
    } else {
        return null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:GUIBrowser.java


注:本文中的javax.swing.JTree.getSelectionPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。