Java 8 DefaultTreeCellRenderer - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DefaultTreeCellRenderer class.

This code example shows how to use the following methods:setClosedIcon, setLeafIcon, setOpenIcon
    ikTreeCellRenderer = new DefaultTreeCellRenderer();
    ikTreeCellRenderer.setOpenIcon(createImageIcon("images/ik_open.png"));
    ikTreeCellRenderer.setClosedIcon(createImageIcon("images/ik_closed.png"));
    ikTreeCellRenderer.setLeafIcon(createImageIcon("images/ik_leaf.png"));
 
    pkTreeCellRenderer = new DefaultTreeCellRenderer();
    pkTreeCellRenderer.setOpenIcon(createImageIcon("images/pk_open.png"));
    pkTreeCellRenderer.setClosedIcon(createImageIcon("images/pk_closed.png"));
    pkTreeCellRenderer.setLeafIcon(createImageIcon("images/pk_leaf.png"));
  } 
   
  @Override 
  public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf,
      int row, boolean hasFocus) {
    TreeCellRenderer delegate = getTreeCellRenderer(value);
    return delegate.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
  } 
 
  private TreeCellRenderer getTreeCellRenderer(Object value) {
    if (value instanceof DefaultMutableTreeNode){
6
CodeRank
This code example shows how to use the following methods:setClosedIcon, setLeafIcon, setOpenIcon
	 
	/** 
	 * @param value 
	 */ 
	protected void setNodeIcon(DefaultTreeCellRenderer renderer, AWorkspaceTreeNode wsNode) {
		renderer.setOpenIcon(DEFAULT_FOLDER_OPEN_ICON);
		renderer.setClosedIcon(DEFAULT_FOLDER_CLOSED_ICON);
		 
		if(wsNode.setIcons(renderer)) {
			return; 
		}		 
		if(!wsNode.isLeaf() || wsNode instanceof AFolderNode) {
			renderer.setLeafIcon(DEFAULT_FOLDER_CLOSED_ICON);
		}  
		else { 
			renderer.setLeafIcon(DEFAULT_ICON);
		} 
		 
		 
	} 
	/*********************************************************************************** 
6
CodeRank
This code example shows how to use the following methods:setClosedIcon, setLeafIcon, setOpenIcon
 
	/** 
	 * @param value 
	 */ 
	protected void setNodeIcon(DefaultTreeCellRenderer renderer, AWorkspaceTreeNode wsNode) {
		renderer.setOpenIcon(DEFAULT_FOLDER_OPEN_ICON);
		renderer.setClosedIcon(DEFAULT_FOLDER_CLOSED_ICON);
		 
		if(wsNode.setIcons(renderer)) {
			return; 
		}		 
		if(!wsNode.isLeaf() || wsNode instanceof AFolderNode) {
			renderer.setLeafIcon(DEFAULT_FOLDER_CLOSED_ICON);
		}  
		else { 
			renderer.setLeafIcon(DEFAULT_ICON);
		} 
		 
		 
	} 
	 
6
CodeRank
This code example shows how to use the following methods:setClosedIcon, setLeafIcon, setOpenIcon
This code example shows how to use the following methods:getTreeCellRendererComponent
This code example shows how to use the following methods:setClosedIcon, setLeafIcon, setOpenIcon
			}); 
		} 
	} 
	 
	public boolean setIcons(DefaultTreeCellRenderer renderer) {
		renderer.setOpenIcon(DEFAULT_ICON);
		renderer.setClosedIcon(DEFAULT_ICON);
		renderer.setLeafIcon(DEFAULT_ICON);
		return true; 
	} 
 
	public void handleAction(WorkspaceActionEvent event) {
		if (event.getType() == WorkspaceActionEvent.MOUSE_RIGHT_CLICK) {	
			showPopup( (Component) event.getBaggage(), event.getX(), event.getY());
		} 
	} 
	 
	 
	public AWorkspaceTreeNode clone() { 
		FolderVirtualNode node = new FolderVirtualNode(getType());
5
CodeRank
This code example shows how to use the following methods:setClosedIcon, setLeafIcon, setOpenIcon
	public String getId() {
		return getProjectID() == null ? Integer.toHexString("".hashCode()).toUpperCase() : getProjectID();
	} 
	 
	public boolean setIcons(DefaultTreeCellRenderer renderer) {
		renderer.setOpenIcon(DEFAULT_ICON);
		renderer.setClosedIcon(DEFAULT_ICON);
		renderer.setLeafIcon(DEFAULT_ICON);
		return true; 
	} 
 
	protected AWorkspaceTreeNode clone(ProjectRootNode node) {
		return super.clone(node);
	} 
		 
	/*********************************************************************************** 
	 * REQUIRED METHODS FOR INTERFACES 
	 **********************************************************************************/ 
	 
	public void handleAction(WorkspaceActionEvent event) {
5
CodeRank
This code example shows how to use the following methods:setClosedIcon, setLeafIcon, setOpenIcon
		//always show the localized node name 
		return TextUtils.getText("docear.node.downloads");
	} 
 
	public boolean setIcons(DefaultTreeCellRenderer renderer) {
		renderer.setOpenIcon(FOLDER_DOWNLOADS_ICON);
		renderer.setClosedIcon(FOLDER_DOWNLOADS_ICON);
		renderer.setLeafIcon(FOLDER_DOWNLOADS_ICON);
		return true; 
	} 
 
	public boolean isSystem() { 
		return true; 
	} 
 
	public void treeExpanded(TreeExpansionEvent event) {
		if(firstExpand) {
			firstExpand  = false;
			this.refresh();
		} 
5
CodeRank
This code example shows how to use the following methods:setClosedIcon, setLeafIcon, setOpenIcon
	} 
	 
	public boolean setIcons(DefaultTreeCellRenderer renderer) {
		File file = URIUtils.getAbsoluteFile(getLinkURI());
		if((file == null || !file.exists()) && !isSystem()) {
			renderer.setLeafIcon(NOT_EXISTING);
			renderer.setOpenIcon(NOT_EXISTING);
			renderer.setClosedIcon(NOT_EXISTING);
			return true; 
		} 
		if(fileIcon == null) {
			if(linkPath != null) {			
				fileIcon = WorkspaceController.getCurrentModeExtension().getView().getNodeTypeIconManager().getIconForNode(this);
			} 
		} 
				 
		if(fileIcon == null) {	
			fileIcon = FileSystemView.getFileSystemView().getSystemIcon(file);
			if(fileIcon != null) {
				renderer.setLeafIcon(fileIcon);

5
CodeRank
This code example shows how to use the following methods:setClosedIcon, setLeafIcon, setOpenIcon
			event.consume();
		} 
	} 
	 
	public boolean setIcons(DefaultTreeCellRenderer renderer) {
		renderer.setOpenIcon(FOLDER_OPEN_ICON);
		renderer.setClosedIcon(FOLDER_CLOSED_ICON);
		renderer.setLeafIcon(FOLDER_CLOSED_ICON);
		return true; 
	} 
 
	public String toString() {
		return this.getClass().getSimpleName() + "[id=" + this.getId() + ";name=" + this.getName() + ";path="
				+ this.getPath() + "]";
	} 
 
	public void refresh() { 
		File folder;
		try { 
			folder = URIUtils.getAbsoluteFile(getPath());
5
CodeRank
See Code Examples for Java 8 DefaultTreeCellRenderer Methods: