本文整理汇总了Java中javax.swing.event.TreeSelectionEvent.getPaths方法的典型用法代码示例。如果您正苦于以下问题:Java TreeSelectionEvent.getPaths方法的具体用法?Java TreeSelectionEvent.getPaths怎么用?Java TreeSelectionEvent.getPaths使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.event.TreeSelectionEvent
的用法示例。
在下文中一共展示了TreeSelectionEvent.getPaths方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入方法依赖的package包/类
@Override
public void valueChanged(TreeSelectionEvent evt) {
// Get all nodes whose selection status has changed
TreePath[] paths = evt.getPaths();
if (paths.length > 0
&& evt.isAddedPath(0)
&& paths[0].getLastPathComponent() instanceof DefaultMutableTreeNode) {
if (((DefaultMutableTreeNode) paths[0].getLastPathComponent())
.isLeaf()
&& !((DefaultMutableTreeNode) paths[0]
.getLastPathComponent()).isRoot()) {
// a leaf has been selected, allow delete relation
deleteRelationButton.setEnabled(true);
} else {
deleteRelationButton.setEnabled(false);
}
}
}
示例2: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入方法依赖的package包/类
public void valueChanged(TreeSelectionEvent e) {
TreePath[] paths = e.getPaths();
selectedNodes.clear();
for (TreePath path : paths) {
boolean appended = false;
StringBuilder sb = new StringBuilder();
Object[] pathArray = path.getPath();
for (Object o : pathArray) {
if (o != null) {
String nodeName = o.toString();
if (nodeName != null) {
if (nodeName.length() > 0) {
appended = true;
sb.append("/"); //$NON-NLS-1$
sb.append(o.toString());
}
}
}
}
if (appended) {
selectedNodes.add(sb.toString());
}
}
for (int i = 0; i < needsReload.size(); i++) {
this.needsReload.set(i, true);
}
reloadSelectedViewer();
}