本文整理匯總了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");
}
}
}