Java Code Examples for javax.swing.tree.TreeNode#equals()

The following examples show how to use javax.swing.tree.TreeNode#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DnDCellRendererProxy.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Component getTreeCellRendererComponent(JTree tree, Object value,
		boolean selected, boolean expanded, boolean leaf, int row,
		boolean hasFocus) {
	Component c = this.originalTreeCellRenderer
			.getTreeCellRendererComponent(tree, value, selected, expanded,
					leaf, row, hasFocus);

	TreeNode nodeToRender = (TreeNode) value;

	if (c instanceof JComponent) {
		if (this.fetchBorder) {
			this.fetchBorder = false;
			this.originalBorder = ((JComponent) c).getBorder();
		}
		// TODO: This *REMOVES* the border in c.
		// TODO: Use compound borders to draw BOTH borders.
		JComponent jComponent = (JComponent) c;
		if (nodeToRender.equals(this.dropNode)) {
			Border border = null;
			if (this.isDropAllowed()) {
				border = this.borderFactory.getDropAllowedBorder();
				this.dropNodeRow = row;
			} else {
				border = this.borderFactory.getDropNotAllowedBorder();
				this.dropNodeRow = -2;
			}
			jComponent.setBorder(border);
		} else if (this.isDropAllowed() && (row == this.dropNodeRow + 1)) {
			jComponent.setBorder(this.borderFactory.getOffsetBorder());
		} else {
			jComponent.setBorder(this.originalBorder);
			this.dropNodeRow = -2;
		}
	}
	return c;
}
 
Example 2
Source File: ListTreeNode.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public int getIndex(TreeNode node) {
	for (int i = 0; i < children.size(); i++) {
		if (node != null && node.equals(children.get(i)))
			return i;
	}
	// not found
	return -1;
}