javax.swing.JTree.getForeground()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(107)

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

JTree.getForeground介绍

暂无

代码示例

代码示例来源:origin: org.appdapter/org.appdapter.lib.gui

@Override public Component getTreeCellRendererComponent(JTree table, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    return renderComponent(table, value, row, -1, selected, -1, table.getForeground(), table.getBackground());
  }
}

代码示例来源:origin: org.apache.river.examples/browser

public Component getTreeCellRendererComponent(JTree tree,
            Object value,
            boolean isSelected,
            boolean isExpanded,
            boolean isLeaf,
            int row,
            boolean cellHasFocus){
  //label.setFont(tree.getFont());
  label.setForeground(tree.getForeground());
  if(isSelected){
 //label.setBackground(UIManager.getColor("Tree.backgroundSelectionColor"));
 //label.setForeground(UIManager.getColor("Tree.textSelectionColor"));
 label.setBackground(MetalLookAndFeel.getPrimaryControl());
  } else {
 //label.setBackground(UIManager.getColor("Tree.backgroundNonSelectionColor"));
 //label.setForeground(UIManager.getColor("Tree.textNonSelectionColor"));
 label.setBackground(tree.getBackground());
  }
  ObjectNode node = (ObjectNode) value;
  label.setText(node.getTitle());
  label.setIcon(node.getIcon());
  return label;
 }
}

代码示例来源:origin: jcbvm/i18n-editor

@Override 
  public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, 
      boolean leaf, int row, boolean hasFocus) {
    TranslationTreeNode node = (TranslationTreeNode) value;
    TranslationTreeModel model = (TranslationTreeModel) tree.getModel();
    JLabel l = (JLabel) super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
    l.setOpaque(true);
    l.setForeground(tree.getForeground());
    l.setBackground(tree.getBackground());                
    if (!node.isRoot() && (node.hasError() || model.hasErrorChildNode(node))) {
      l.setIcon(new TranslationTreeStatusIcon(StatusIconType.Warning));
    }
    if (node.isRoot()) {
      l.setIcon(ROOT_ICON);
    }
    if (selected) {
      l.setBackground(selectionBackground);
    }
    return l;
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-modelutil

label.setForeground(tree.getForeground());
panel.setOpaque(false);

代码示例来源:origin: antlr/intellij-plugin-v4

public void renderTreeNode(SimpleColoredComponent component, JTree tree) {
  String literal = getText();
  SimpleTextAttributes attributes =
    new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, tree.getForeground());
  component.append(literal, attributes);
  component.setIcon(icon);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

@Override
  public Component getTreeCellRendererComponent(JTree tree, Object value,
      boolean isSelected, boolean expanded,
      boolean leaf, int row, boolean hasFocus) {
    String stringValue = tree.convertValueToText(value, isSelected,
        expanded, leaf, row, hasFocus);
    setEnabled(tree.isEnabled());
    if (value instanceof CheckNode) {
      CheckNode n = (CheckNode) value;
      check.setSelected(n.isSelected());
      label.setIcon(new ImageIcon(n.getIcon())); // XXX Ask description directly
    }
    if (isSelected) {
      label.setForeground(LIST_FOR_COLORS.getSelectionForeground());
      setOpaque(true);
      setBackground(LIST_FOR_COLORS.getSelectionBackground());
    } else {
      label.setForeground(tree.getForeground());
      setOpaque(false);
    }
    label.setText(stringValue);
    return this;
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-editor

@Override
  public Component getTreeCellRendererComponent(JTree tree, Object value,
      boolean isSelected, boolean expanded,
      boolean leaf, int row, boolean hasFocus) {
    String stringValue = tree.convertValueToText(value, isSelected,
        expanded, leaf, row, hasFocus);
    setEnabled(tree.isEnabled());
    if (value instanceof TypeNode) {
      TypeNode n = (TypeNode) value;
      stringValue = n.toStringAsHtml();
      label.setIcon(new ImageIcon(n.getIcon()));
    }
    if (isSelected) {
      label.setForeground(LIST_FOR_COLORS.getSelectionForeground());
      setOpaque(true);
      setBackground(LIST_FOR_COLORS.getSelectionBackground());
    } else {
      label.setForeground(tree.getForeground());
      setOpaque(false);
    }
    label.setText(stringValue);
    return this;
  }
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

public Component getTreeCellRendererComponent(final JTree _tree, final Object _value, final boolean _selected,
  final boolean _expanded, final boolean _leaf, final int _row, final boolean _hasFocus) {
 if (treeSelectionForeground_ == null) {
  treeSelectionForeground_ = UIManager.getColor("Tree.selectionForeground");
 }
 if (treeSelectionBackground_ == null) {
  treeSelectionBackground_ = UIManager.getColor("Tree.selectionBackground");
 }
 if (_selected) {
  setBackground(treeSelectionBackground_);
  setForeground(treeSelectionForeground_);
 } else {
  setBackground(_tree.getBackground());
  setForeground(_tree.getForeground());
 }
 setValue(_value);
 return this;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-java-hints-analyzer

label.setForeground(tree.getForeground());
setOpaque(false);

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

@Override
  public Component getTreeCellRendererComponent(JTree tree, Object value,
  boolean isSelected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    if(!(value instanceof FileNode)) {
      return this;
    }
    FileNode node = (FileNode) value;
    stringDisplayer = renderer.getTreeCellRendererComponent(tree, 
      node.getText(), isSelected, expanded, leaf, row, hasFocus);

    if(!(value instanceof StoreEntryNode)) {
//            renderer.setIcon (null);
    }
    stringDisplayer.setEnabled(value instanceof StoreEntryNode);

    //HtmlRenderer does not tolerate null colors - real ones are needed to
    //ensure fg/bg always diverge enough to be readable
    if (stringDisplayer.getBackground() == null) {
      stringDisplayer.setBackground (tree.getBackground());
    }
    if (stringDisplayer.getForeground() == null) {
      stringDisplayer.setForeground (tree.getForeground());
    }

    if (check != null) {
      check.setSelected(node.isSelected());
    }
    return this;
  }

代码示例来源:origin: it.tidalwave.netbeans/it-tidalwave-netbeans-explorer

/*******************************************************************************
 *
 *
 ******************************************************************************/
private void patchRenderer()
 {
  if (Boolean.getBoolean("nb.useSwingHtmlRendering") && !rendererPatched)
   {
    rendererPatched = true;
    final OldPatchedNodeRenderer nodeRenderer = new OldPatchedNodeRenderer(tree.getCellRenderer());
    nodeRenderer.setBackgroundSelectionColor(getColorProperty("Tree.selectionBackground"));
    nodeRenderer.setBackgroundNonSelectionColor(tree.getBackground());
    nodeRenderer.setTextSelectionColor(getColorProperty("Tree.selectionForeground"));
    nodeRenderer.setTextNonSelectionColor(tree.getForeground());
    tree.setCellRenderer(nodeRenderer);
   }
 }

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project

stringDisplayer.setForeground(tree.getForeground());

代码示例来源:origin: org.fudaa.framework.ebli/ebli-2d

public Component getTreeCellRendererComponent(final JTree _tree, final Object _value, final boolean _selected,
   final boolean _expanded, final boolean _leaf, final int _row, final boolean _hasFocus) {
  this.setFont(_tree.getFont());
  setIcon(((LayerNode) _value).getIcon());
  setText(_value.toString());
  final boolean selectable = isSelectable(_value, _leaf);
  if (_selected && selectable) {
   setBackground(selectedBackground_);
   setForeground(selectedForground_);
  } else {
   setBackground(_tree.getBackground());
   setForeground(_tree.getForeground());
  }
  if (selectable) {
   setToolTipText(getText());
  } else {
   setToolTipText(getText() + ": " + CtuluLib.getS("Non slectionnable"));
  }
  setBorder((selectable && _hasFocus) ? focusBorderColor_ : CtuluCellRenderer.BORDER_NO_FOCUS);
  setEnabled(_tree.isEnabled());
  return this;
 }
}

代码示例来源:origin: org.fudaa.framework.ebli/ebli-2d

public Component getTreeCellRendererComponent(final JTree _tree, final Object _value, final boolean _selected,
   final boolean _expanded, final boolean _leaf, final int _row, final boolean _hasFocus) {
  this.setFont(_tree.getFont());
  setIcon(((LayerNode) _value).getIcon());
  setText(_value.toString());
  final boolean selectable = isSelectable(_value, _leaf);
  if (_selected && selectable) {
   setBackground(selectedBackground_);
   setForeground(selectedForground_);
  } else {
   setBackground(_tree.getBackground());
   setForeground(_tree.getForeground());
  }
  if (selectable) {
   setToolTipText(getText());
  } else {
   setToolTipText(getText() + ": " + CtuluLib.getS("Non slectionnable"));
  }
  setBorder((selectable && _hasFocus) ? focusBorderColor_ : CtuluCellRenderer.BORDER_NO_FOCUS);
  setEnabled(_tree.isEnabled());
  return this;
 }
}

相关文章

JTree类方法