javax.swing.JTree.setSelectionInterval()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中javax.swing.JTree.setSelectionInterval()方法的一些代码示例,展示了JTree.setSelectionInterval()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.setSelectionInterval()方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:setSelectionInterval

JTree.setSelectionInterval介绍

暂无

代码示例

代码示例来源:origin: triplea-game/triplea

  1. private void previous() {
  2. if (tree.getSelectionCount() == 0) {
  3. tree.setSelectionInterval(0, 0);
  4. return;
  5. }
  6. final TreePath path = tree.getSelectionPath();
  7. final TreeNode selected = (TreeNode) path.getLastPathComponent();
  8. @SuppressWarnings("unchecked")
  9. final Enumeration<TreeNode> nodeEnum =
  10. ((DefaultMutableTreeNode) tree.getModel().getRoot()).depthFirstEnumeration();
  11. TreeNode previous = null;
  12. while (nodeEnum.hasMoreElements()) {
  13. final TreeNode current = nodeEnum.nextElement();
  14. if (current == selected) {
  15. break;
  16. } else if (current.getParent() instanceof Step) {
  17. previous = current;
  18. }
  19. }
  20. if (previous != null) {
  21. navigateTo(previous);
  22. }
  23. }

代码示例来源:origin: triplea-game/triplea

  1. private void next() {
  2. if (tree.getSelectionCount() == 0) {
  3. tree.setSelectionInterval(0, 0);
  4. return;
  5. }
  6. final TreePath path = tree.getSelectionPath();
  7. final TreeNode selected = (TreeNode) path.getLastPathComponent();
  8. @SuppressWarnings("unchecked")
  9. final Enumeration<TreeNode> nodeEnum = ((DefaultMutableTreeNode) tree.getModel().getRoot()).preorderEnumeration();
  10. TreeNode next = null;
  11. boolean foundSelected = false;
  12. while (nodeEnum.hasMoreElements()) {
  13. final TreeNode current = nodeEnum.nextElement();
  14. if (current == selected) {
  15. foundSelected = true;
  16. } else if (foundSelected) {
  17. if (current.getParent() instanceof Step) {
  18. next = current;
  19. break;
  20. }
  21. }
  22. }
  23. if (next != null) {
  24. navigateTo(next);
  25. }
  26. }

代码示例来源:origin: net.sf.ingenias/ingeniasjgraphmod

  1. tree.setSelectionInterval(0, 0);

相关文章

JTree类方法