當前位置: 首頁>>代碼示例>>Java>>正文


Java TreeSelectionEvent類代碼示例

本文整理匯總了Java中javax.swing.event.TreeSelectionEvent的典型用法代碼示例。如果您正苦於以下問題:Java TreeSelectionEvent類的具體用法?Java TreeSelectionEvent怎麽用?Java TreeSelectionEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TreeSelectionEvent類屬於javax.swing.event包,在下文中一共展示了TreeSelectionEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: valueChanged

import javax.swing.event.TreeSelectionEvent; //導入依賴的package包/類
@Override
public void valueChanged(TreeSelectionEvent ev) {
    TreePath[] paths = tree.getSelectionPaths();

    if (paths == null) {
        // part of bugfix #37279, if DnD is active then is useless select a nearby node
        if (ExplorerDnDManager.getDefault().isDnDActive()) {
            return;
        }

        callSelectionChanged(new Node[0]);
    } else {
        // we need to force no changes to nodes hierarchy =>
        // we are requesting read request, but it is not necessary
        // to execute the next action immediatelly, so postReadRequest
        // should be enough
        readAccessPaths = paths;
        Children.MUTEX.postReadRequest(this);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:TreeView.java

示例2: HintsPanel

import javax.swing.event.TreeSelectionEvent; //導入依賴的package包/類
public HintsPanel(HintMetadata preselected, @NullAllowed final CustomizerContext<?, ?> cc, ClassPathBasedHintWrapper cpBased) {
    this.cpBased = cpBased;
    this.queryStatus = cc == null ? QueryStatus.NEVER : QueryStatus.SHOW_QUERIES;
    this.showHeavyInspections = true;
    init(null, true, false, false, false, cc == null, false, cc != null);
    select(preselected);
    configurationsPanel.setVisible(false);
    
    if (cc != null) {
        errorTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
            @Override public void valueChanged(TreeSelectionEvent e) {
                HintMetadata hm = getSelectedHint();

                if (hm != null) {
                    cc.setSelectedId(AnalyzerImpl.ID_JAVA_HINTS_PREFIX + hm.id);
                }
            }
        });
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:HintsPanel.java

示例3: 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();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:PathsCustomizer.java

示例4: valueChanged

import javax.swing.event.TreeSelectionEvent; //導入依賴的package包/類
@Override
public void valueChanged(TreeSelectionEvent e) {
	TreePath newLeadSelectionPath = e.getNewLeadSelectionPath();
	if (newLeadSelectionPath == null) {
		return;
	}
	Object lastPathComponent = newLeadSelectionPath.getLastPathComponent();
	if (lastPathComponent instanceof ValueSourceTreeNode) {

		ValueSourceTreeNode valueSourceNode = (ValueSourceTreeNode) lastPathComponent;
		// get the selected PVC
		ValueSource selectedValueSource = valueSourceNode.getUserObject();

		if (selectedValueSource == currentValueSource) {
			return;
		}

		// change current PlotValueConfig
		currentValueSource = selectedValueSource;

	} else {
		currentValueSource = null;
	}

}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:26,代碼來源:DataTableColumnDropTextFieldTransferHandler.java

示例5: valueChanged

import javax.swing.event.TreeSelectionEvent; //導入依賴的package包/類
@Override
public void valueChanged(TreeSelectionEvent e) {
	TreePath newLeadSelectionPath = e.getNewLeadSelectionPath();
	if (newLeadSelectionPath == null) {
		selectedRangeAxisConfig = null;
		return;
	}
	Object lastPathComponent = newLeadSelectionPath.getLastPathComponent();
	if (lastPathComponent instanceof RangeAxisConfigTreeNode) {

		RangeAxisConfig selectedConfig = ((RangeAxisConfigTreeNode) lastPathComponent).getUserObject();

		selectedRangeAxisConfig = selectedConfig;

		adaptGUI();

	} else {
		selectedRangeAxisConfig = null;
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:21,代碼來源:RangeAxisConfigPanel.java

示例6: valueChanged

import javax.swing.event.TreeSelectionEvent; //導入依賴的package包/類
@Override
public void valueChanged(TreeSelectionEvent e) {
	TreePath[] paths = getSelectionPaths();
	// If only one item has been selected, then change the text in the
	// description area
	if (paths == null) {
		return;
	}
	if (paths.length == 1) {
		DefaultMutableTreeNode node = (DefaultMutableTreeNode) paths[0].getLastPathComponent();
		if (!node.getAllowsChildren()) {
			ClusterTreeLeaf leaf = (ClusterTreeLeaf) node.getUserObject();
			ObjectVisualizer viz = ObjectVisualizerService.getVisualizerForObject(clusterModel);
			viz.startVisualization(leaf.getId());
		}
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:18,代碼來源:ClusterTreeVisualization.java

示例7: AvailableTreeTable

import javax.swing.event.TreeSelectionEvent; //導入依賴的package包/類
public AvailableTreeTable() {
	super();
	setTreeTableModel(new AvailableTreeTableModel(data.getRoot()));
	sizeColumns();
	setRowHeight(CELL_HEIGHT);
	setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	getTableHeader().setReorderingAllowed(false);

	addTreeSelectionListener(new TreeSelectionListener() {
		@Override
		public void valueChanged(TreeSelectionEvent e) {
			TreePath path = e.getPath();
			TreeTableNode node = (TreeTableNode) path.getLastPathComponent();
			if ("template".equals(node.getType())) {
				tempDownload.setEnabled(true);
			} else {
				tempDownload.setEnabled(false);
			}
		}
	});
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:22,代碼來源:TemplateAddingPanel.java

示例8: valueChanged

import javax.swing.event.TreeSelectionEvent; //導入依賴的package包/類
/** Required by TreeSelectionListener interface. */
public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();

    if (node == null)
        return;

    Object nodeInfo = node.getUserObject();
    if (node.isLeaf()) {
        BookInfo book = (BookInfo) nodeInfo;
        displayURL(book.bookURL);
        if (DEBUG) {
            System.out.print(book.bookURL + ":  \n    ");
        }
    } else {
        displayURL(helpURL);
    }
    if (DEBUG) {
        System.out.println(nodeInfo.toString());
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:22,代碼來源:TreeDemo.java

示例9: valueChanged

import javax.swing.event.TreeSelectionEvent; //導入依賴的package包/類
public void valueChanged(TreeSelectionEvent e) {
  super.valueChanged(e);

  final TreePath p = e.getPath();
  if (p != null) {
    final DefaultMutableTreeNode node =
      (DefaultMutableTreeNode) p.getLastPathComponent();

    Object x[] = node.getUserObjectPath();
    Configurable[] userObjectPath = new Configurable[x.length];

    for (int i = 0; i < x.length; i++) {
      userObjectPath[i] = (Configurable) x[i];
    }

    path = ArrayUtils.copyOfRange(userObjectPath, 1, userObjectPath.length);
  }
  else {
    path = null;
  }
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:22,代碼來源:ChooseComponentPathDialog.java

示例10: valueChanged

import javax.swing.event.TreeSelectionEvent; //導入依賴的package包/類
/** Required by TreeSelectionListener interface. */
public void valueChanged(TreeSelectionEvent e) {
    DefaultMutableTreeNode node = (DefaultMutableTreeNode)
                       tree.getLastSelectedPathComponent();

    if (node == null) return;

    Object nodeInfo = node.getUserObject();
    if (node.isLeaf()) {
        BookInfo book = (BookInfo)nodeInfo;
        displayURL(book.bookURL);
        if (DEBUG) {
            System.out.print(book.bookURL + ":  \n    ");
        }
    } else {
        displayURL(helpURL); 
    }
    if (DEBUG) {
        System.out.println(nodeInfo.toString());
    }
}
 
開發者ID:OpenDA-Association,項目名稱:OpenDA,代碼行數:22,代碼來源:TreeDemo.java

示例11: OurTree

import javax.swing.event.TreeSelectionEvent; //導入依賴的package包/類
/** Construct a Tree object with the given font size. */
public OurTree(int fontSize) {
	Font font = OurUtil.getVizFont().deriveFont((float) fontSize);
	OurTreeRenderer renderer = new OurTreeRenderer(fontSize);
	renderer.setFont(font);
	renderer.invalidate();
	renderer.validate();
	setRowHeight(0); // To allow variable row height on Mac OS X
	setCellRenderer(renderer);
	setFont(font);
	setBorder(new EmptyBorder(8, 8, 2, 2));
	getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	putClientProperty("JTree.lineStyle", "Angled");
	setRootVisible(true);
	setForeground(Color.BLACK);
	setBackground(Color.WHITE);
	setOpaque(true);
	addTreeSelectionListener(new TreeSelectionListener() {
		public void valueChanged(TreeSelectionEvent e) {
			TreePath path = OurTree.this.getSelectionPath();
			if (path != null)
				OurTree.this.listeners.fire(OurTree.this, Listener.Event.CLICK, path.getLastPathComponent());
		}
	});
}
 
開發者ID:AlloyTools,項目名稱:org.alloytools.alloy,代碼行數:26,代碼來源:OurTree.java

示例12: valueChanged

import javax.swing.event.TreeSelectionEvent; //導入依賴的package包/類
/**
 * Emphasises/deemphasises cells in the associated jmodel, based on the list
 * selection.
 */
@Override
public void valueChanged(TreeSelectionEvent e) {
    Set<JCell<?>> emphSet = new HashSet<>();
    TreePath[] selectionPaths = getSelectionPaths();
    if (selectionPaths != null) {
        for (TreePath selectedPath : selectionPaths) {
            Object treeNode = selectedPath.getLastPathComponent();
            if (treeNode instanceof LabelTree.EntryNode) {
                Entry entry = ((EntryNode) treeNode).getEntry();
                Set<JCell<G>> occurrences = getFilter().getJCells(entry);
                if (occurrences != null) {
                    emphSet.addAll(occurrences);
                }
            }
        }
    }
    this.jGraph.setSelectionCells(emphSet.toArray());
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:23,代碼來源:LabelTree.java

示例13: createInnerComponent

import javax.swing.event.TreeSelectionEvent; //導入依賴的package包/類
protected void createInnerComponent() {
    panel.removeAll();
    Attribute[] attributes = getAttributes();
    RootCreater rootCreater = getRootCreater();

    component = new RowTreeTableComponent(engine, qualifier, accessRules,
            rootCreater, attributes, framework);

    rowSet = component.getRowSet();
    table = component.getTable();

    table.getTreeSelectionModel().addTreeSelectionListener(
            new TreeSelectionListener() {
                @Override
                public void valueChanged(TreeSelectionEvent e) {
                    refreshActions();
                }
            });
    refreshActions();
    panel.add(component, BorderLayout.CENTER);
    panel.revalidate();
    panel.repaint();
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:24,代碼來源:AbstractTableView.java

示例14: valueChanged

import javax.swing.event.TreeSelectionEvent; //導入依賴的package包/類
/**
 * This function analyses a tree selection event and calls the
 * right methods to take care of building the requested unit's
 * details.
 *
 * @param event The incoming TreeSelectionEvent.
 */
@Override
public void valueChanged(TreeSelectionEvent event) {
    detailPanel.removeAll();
    DefaultMutableTreeNode node
        = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
    if (node != null) {
        if (node.isLeaf()) {
            OptionGroup group = (OptionGroup) node.getUserObject();
            for (Option option : group.getOptions()) {
                addOptionUI(option, editable && group.isEditable());
            }
        } else {
            tree.expandPath(event.getPath());
        }
    }
    detailPanel.revalidate();
    detailPanel.repaint();
}
 
開發者ID:FreeCol,項目名稱:freecol,代碼行數:26,代碼來源:OptionGroupUI.java

示例15: 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);
        }
    }

}
 
開發者ID:CLARIN-PL,項目名稱:WordnetLoom,代碼行數:21,代碼來源:ViwnLexicalUnitRelationsViewUI.java


注:本文中的javax.swing.event.TreeSelectionEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。