本文整理汇总了Java中javax.swing.event.TreeSelectionEvent.isAddedPath方法的典型用法代码示例。如果您正苦于以下问题:Java TreeSelectionEvent.isAddedPath方法的具体用法?Java TreeSelectionEvent.isAddedPath怎么用?Java TreeSelectionEvent.isAddedPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.event.TreeSelectionEvent
的用法示例。
在下文中一共展示了TreeSelectionEvent.isAddedPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入方法依赖的package包/类
@Override
public void valueChanged(TreeSelectionEvent e) {
if (e.isAddedPath()) {
otherTreeSelectionModel.clearSelection();
}
int idx = treeModel.getIndexOfChild(treeModel.getRoot(), e.getPath().getLastPathComponent());
if (idx >= 0) {
if (otherListModel != null) {
idx += otherListModel.getSize() + 1;
}
if (e.isAddedPath()) {
list.setSelectionInterval(idx, idx);
} else {
list.removeSelectionInterval(idx, idx);
}
} else {
list.clearSelection();
}
}
示例2: 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);
}
}
}
示例3: valueChanged
import javax.swing.event.TreeSelectionEvent; //导入方法依赖的package包/类
public void valueChanged(TreeSelectionEvent arg0) {
if ( arg0.getSource() == tree ) {
if ( arg0.isAddedPath() ) {
// System.out.println("Added selection path");
openTreePaths.add(arg0.getPath());
} else {
// System.out.println("Removed selection path");
}
}
}