Java 8 TreeCellRenderer - 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 TreeCellRenderer class.

This code example shows how to use the following methods:getTreeCellRendererComponent
This code example shows how to use the following methods:getTreeCellRendererComponent
This code example shows how to use the following methods:getTreeCellRendererComponent
                updateCheckBoxState(_checkBox, path, selectionModel);
            } 
        } 
 
        if (_actualTreeRenderer != null) {
            JComponent treeCellRendererComponent = (JComponent) _actualTreeRenderer.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
            Border border = treeCellRendererComponent.getBorder();
            setBorder(border);
            treeCellRendererComponent.setBorder(BorderFactory.createEmptyBorder());
            if (path == null || !(tree instanceof CheckBoxTree) || ((CheckBoxTree) tree).isCheckBoxVisible(path)) {
                remove(_emptyBox);
                add(_checkBox, BorderLayout.BEFORE_LINE_BEGINS);
            } 
            else { 
                remove(_checkBox);
                add(_emptyBox, BorderLayout.AFTER_LINE_ENDS); // expand the tree node size to be the same as the one with check box.
            } 
            add(treeCellRendererComponent);
 
            // copy the background and foreground for the renderer component 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTreeCellRendererComponent
        boolean isSelected = tree.isPathSelected(treePath);
        boolean isExpanded = tree.isExpanded(treePath);
        boolean hasFocus = tree.hasFocus() && rowIndex == tree.getLeadSelectionRow();
        Object item = treePath.getLastPathComponent();
        boolean isLeaf = treeModel.isLeaf(item);
        Component component = renderer.getTreeCellRendererComponent(tree, item, isSelected, isExpanded, isLeaf, rowIndex, hasFocus);
        component.setFont(tree.getFont());
        return component;
    } 
 
    public boolean equals(Object o) { 
        if(this == o) {
            return true; 
        } 
        if(o == null || getClass() != o.getClass()) {
            return false; 
        } 
 
        TreeDataTipCell treeDataTipCell = (TreeDataTipCell) o;
 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTreeCellRendererComponent
   
  @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){
      value = ((DefaultMutableTreeNode) value).getUserObject();
    } 
    if (value instanceof PointerKey){ 
      return pkTreeCellRenderer;
    } else if (value instanceof InstanceKey){ 
      return ikTreeCellRenderer;
    } else { 
      return defaultTreeCellRenderer;
    } 
  } 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTreeCellRendererComponent
   */ 
  @Override 
  @RunsInCurrentThread 
  public @Nullable String valueAt(@Nonnull JTree tree, @Nullable Object modelValue) {
    TreeCellRenderer r = tree.getCellRenderer();
    Component c = r.getTreeCellRendererComponent(tree, modelValue, false, false, false, 0, false);
    String value = (c != null) ? rendererReader.valueFrom(c) : null;
    if (value != null) {
      return value;
    } 
    value = tree.convertValueToText(modelValue, false, false, false, 0, false);
    if (isDefaultToString(value)) {
      return null; 
    } 
    return value;
  } 
} 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTreeCellRendererComponent
        checkBox.setOpaque(false);
    } 
 
 
    public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
        Component renderer = delegate.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
 
        TreePath path = tree.getPathForRow(row);
        if (path != null) {
            if (selectionModel.isPathSelected(path, selectionModel.isDigged())) {
                checkBox.setState(Boolean.TRUE);
            } else { 
                checkBox.setState(selectionModel.isDigged() && selectionModel.isPartiallySelected(path) ? null : Boolean.FALSE);
            } 
        } 
        removeAll();
        checkBox.setVisible(path == null || selectable == null || selectable.isSelectable(path));
        add(checkBox, BorderLayout.WEST);
        add(renderer, BorderLayout.CENTER);
        return this;
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getTreeCellRendererComponent
		setOpaque(false);
		checkBox.setOpaque(false);
	} 
 
	public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf,	int row, boolean hasFocus) {
		Component renderer = delegate.getTreeCellRendererComponent(tree, value,	selected, expanded, leaf, row, hasFocus);
		((DefaultTreeCellRenderer) renderer).setLeafIcon(null);
		((DefaultTreeCellRenderer) renderer).setIcon(null);
		((DefaultTreeCellRenderer) renderer).setOpenIcon(null);
		((DefaultTreeCellRenderer) renderer).setClosedIcon(null);
 
		TreePath path = tree.getPathForRow(row);
		if (path != null) {
			if (selectionModel.isPathSelected(path, true))
				checkBox.setState(Boolean.TRUE);
			else 
				checkBox.setState(selectionModel.isPartiallySelected(path) ? null : Boolean.FALSE);
		} 
		removeAll();
		add(checkBox, BorderLayout.WEST);
3
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 TreeCellRenderer Methods: