javax.swing.tree.TreeCellRenderer.getTreeCellRendererComponent()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(108)

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

TreeCellRenderer.getTreeCellRendererComponent介绍

暂无

代码示例

代码示例来源:origin: groovy/groovy-core

TreeCellRenderer tcr;
  tcr = new DefaultTreeCellRenderer();
  children.add(tcr.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, focused));
} else if (list != null) {
  ListCellRenderer lcr = (ListCellRenderer) UIManager.get("List.cellRenderer");

代码示例来源:origin: stackoverflow.com

Component renderer = delegate.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-inspect

@Override
  public Component getTreeCellRendererComponent(JTree tree,
      Object value, boolean selected, boolean expanded,
      boolean leaf, int row, boolean hasFocus) {
    Component component = renderer.getTreeCellRendererComponent(
        tree, value, selected, expanded, leaf, row, hasFocus);
    if (component instanceof JLabel) {
      ((JLabel)component).setIcon(null);
    }
    return component;
  }
});

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-inspect

@Override
  public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    JLabel component;
    if (!selected && (value == lastHover)) {
      component = (JLabel)delegate.getTreeCellRendererComponent(tree, value, true, expanded, leaf, row, hasFocus);
      component.setBackground(hoverColor);
      component.setOpaque(true);
    } else {
      component = (JLabel)delegate.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
    }
    return component;
  }
};

代码示例来源:origin: sdedit/sdedit

public Component getTreeCellRendererComponent(JTree tree, Object value,
    boolean selected, boolean expanded, boolean leaf, int row,
    boolean hasFocus) {
  JLabel label = (JLabel) existingRenderer.getTreeCellRendererComponent(
      tree, value, selected, expanded, leaf, row, hasFocus);
  if (leaf) {
    label.setIcon(leafIcon);
  } else {
    label.setIcon(nodeIcon);
  }
  return label;
}

代码示例来源:origin: tinyMediaManager/tinyMediaManager

public java.awt.Component getTreeCellRendererComponent(javax.swing.JTree tree, Object value, boolean selected, boolean expanded, boolean leaf,
  int row, boolean hasFocus) {
 final java.awt.Component c = ren.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
 if (selected || !drawStripes)
  return c;
 if (!(c instanceof javax.swing.tree.DefaultTreeCellRenderer))
  c.setBackground(rowColors[row & 1]);
 else
  ((javax.swing.tree.DefaultTreeCellRenderer) c).setBackgroundNonSelectionColor(rowColors[row & 1]);
 return c;
}

代码示例来源:origin: wala/WALA

@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);
}

代码示例来源:origin: com.ibm.wala/com.ibm.wala.core

@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);
}

代码示例来源:origin: UISpec4J/UISpec4J

private Component getRenderedComponent(Object object) {
 TreeCellRenderer renderer = jTree.getCellRenderer();
 return renderer.getTreeCellRendererComponent(jTree, object,
                        false, false, false, 0, false);
}

代码示例来源:origin: protegeproject/protege

protected JComponent getRendererComponent() {
  return (JComponent) tree.getCellRenderer().getTreeCellRendererComponent(tree,
      tree.getSelectionPath().getLastPathComponent(),
      false,
      true,
      true,
      0,
      false);
}

代码示例来源:origin: edu.stanford.protege/org.protege.editor.owl

protected JComponent getRendererComponent() {
  JComponent c = (JComponent) tree.getCellRenderer().getTreeCellRendererComponent(tree,
                                          tree.getSelectionPath().getLastPathComponent(),
                                          false,
                                          true,
                                          true,
                                          0,
                                          false);
  return c;
}

代码示例来源:origin: org.protege/protege-editor-owl

protected JComponent getRendererComponent() {
  JComponent c = (JComponent) tree.getCellRenderer().getTreeCellRendererComponent(tree,
                                          tree.getSelectionPath().getLastPathComponent(),
                                          false,
                                          true,
                                          true,
                                          0,
                                          false);
  return c;
}

代码示例来源:origin: edu.stanford.protege/protege-editor-owl

protected JComponent getRendererComponent() {
  return (JComponent) tree.getCellRenderer().getTreeCellRendererComponent(tree,
      tree.getSelectionPath().getLastPathComponent(),
      false,
      true,
      true,
      0,
      false);
}

代码示例来源:origin: com.github.insubstantial/flamingo

private JLabel getRenderer(Object node) {
  Component renderer = tree.getCellRenderer()
      .getTreeCellRendererComponent(tree, node, false, false,
          tree.getModel().isLeaf(node), 0, false);
  if (renderer instanceof JLabel)
    return (JLabel) renderer;
  return null;
}

代码示例来源:origin: org.swinglabs.swingx/swingx-core

@Override
protected RolloverRenderer getRolloverRenderer(Point location, boolean prepare) {
  TreeCellRenderer renderer = component.getCellRenderer();
  RolloverRenderer rollover = renderer instanceof RolloverRenderer 
    ? (RolloverRenderer) renderer : null;
  if ((rollover != null) && !rollover.isEnabled()) {
    rollover = null;
  }
  if ((rollover != null) && prepare) {
    TreePath path = component.getPathForRow(location.y);
    Object element = path != null ? path.getLastPathComponent() : null;
    renderer.getTreeCellRendererComponent(component, element, false, 
        false, false, 
        location.y, false);
  }
  return rollover;
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

@Override
protected RolloverRenderer getRolloverRenderer(Point location, boolean prepare) {
  TreeCellRenderer renderer = component.getCellRenderer();
  RolloverRenderer rollover = renderer instanceof RolloverRenderer 
    ? (RolloverRenderer) renderer : null;
  if ((rollover != null) && !rollover.isEnabled()) {
    rollover = null;
  }
  if ((rollover != null) && prepare) {
    TreePath path = component.getPathForRow(location.y);
    Object element = path != null ? path.getLastPathComponent() : null;
    renderer.getTreeCellRendererComponent(component, element, false, 
        false, false, 
        location.y, false);
  }
  return rollover;
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

@Override
protected RolloverRenderer getRolloverRenderer(Point location, boolean prepare) {
  TreeCellRenderer renderer = component.getCellRenderer();
  RolloverRenderer rollover = renderer instanceof RolloverRenderer 
    ? (RolloverRenderer) renderer : null;
  if ((rollover != null) && !rollover.isEnabled()) {
    rollover = null;
  }
  if ((rollover != null) && prepare) {
    TreePath path = component.getPathForRow(location.y);
    Object element = path != null ? path.getLastPathComponent() : null;
    renderer.getTreeCellRendererComponent(component, element, false, 
        false, false, 
        location.y, false);
  }
  return rollover;
}

代码示例来源:origin: antlr/antlrworks

public void createDragImage(DragGestureEvent event) {
  Point dragOrigin = event.getDragOrigin();
  TreePath path = getPathForLocation(dragOrigin.x, dragOrigin.y);
  Rectangle r = getPathBounds(path);
  dragImageOffset.setLocation(dragOrigin.x - r.x, dragOrigin.y - r.y);
  JLabel label = (JLabel)getCellRenderer().getTreeCellRendererComponent(this, path.getLastPathComponent(),
      false, isExpanded(path), getModel().isLeaf(path.getLastPathComponent()), 0, false);
  label.setSize(r.width, r.height);
  dragImage = new BufferedImage(r.width, r.height, BufferedImage.TYPE_INT_ARGB_PRE);
  Graphics2D g2d = dragImage.createGraphics();
  g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 0.5f));
  label.paint(g2d);
  g2d.dispose();
}

代码示例来源:origin: robotframework/SwingLibrary

private Component getNodeComponent(Object node, TreePath treePath) {
  int row = tree.getRowForPath(treePath);
  boolean isLeaf = tree.getModel().isLeaf(node);
  boolean hasFocus = tree.getLeadSelectionRow() == row;
  boolean isSelected = tree.isRowSelected(row);
  boolean isExpanded = tree.isExpanded(row);
  TreeCellRenderer cellRenderer = tree.getCellRenderer();
  return cellRenderer.getTreeCellRendererComponent(tree, node, isSelected, isExpanded, isLeaf, row, hasFocus);
}

代码示例来源:origin: io.ultreia.java4all.jaxx/jaxx-widgets-extra

public Component getRendererComponent() {
  TreeModel treeModel = tree.getModel();
  TreePath treePath = tree.getPathForRow(rowIndex);
  TreeCellRenderer renderer = tree.getCellRenderer();
  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());
  // FIX Nimbus white foreground on white background
  if (isSelected) {
    component.setForeground(UIManager.getColor("Tree.textForeground"));
  }
  return component;
}

相关文章