本文整理汇总了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();
}
}
示例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();
}
}
示例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);
// }
// }
// }
}
}
}
}
示例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();
}
}
}
示例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();
}
}
}
}
示例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
}
}
}
}
示例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();
}
}
}
}
示例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();
}
}
}
示例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();
}
}
}
}
示例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();
}
}
}
}
示例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;
}
示例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);
}
示例13: getSelectionPath
import javax.swing.JTree; //导入方法依赖的package包/类
private TreePath getSelectionPath() {
JTree tree = getSelectedTree();
if (tree != null) {
return tree.getSelectionPath();
} else {
return null;
}
}