当前位置: 首页>>代码示例>>Java>>正文


Java JTree.convertValueToText方法代码示例

本文整理汇总了Java中javax.swing.JTree.convertValueToText方法的典型用法代码示例。如果您正苦于以下问题:Java JTree.convertValueToText方法的具体用法?Java JTree.convertValueToText怎么用?Java JTree.convertValueToText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTree的用法示例。


在下文中一共展示了JTree.convertValueToText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTreeCellRendererComponent

import javax.swing.JTree; //导入方法依赖的package包/类
/** This method is called by Swing to return an object to be drawn. */
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean isSelected, boolean expanded,
		boolean isLeaf, int row, boolean isFocused) {
	String string = tree.convertValueToText(value, isSelected, expanded, isLeaf, row, isFocused);
	this.isFocused = isFocused;
	this.isSelected = isSelected;
	setText(string);
	setForeground(UIManager.getColor(isSelected ? "Tree.selectionForeground" : "Tree.textForeground"));
	preferredHeight = 0; // By default, don't override width/height
	if (do_isDouble(value)) {
		Dimension d = super.getPreferredSize();
		preferredWidth = d.width + 3;
		preferredHeight = d.height * 2;
	}
	return this;
}
 
开发者ID:AlloyTools,项目名称:org.alloytools.alloy,代码行数:17,代码来源:OurTree.java

示例2: setText

import javax.swing.JTree; //导入方法依赖的package包/类
/** This method is called by Swing to return an object to be drawn. */
public Component getTreeCellRendererComponent
(JTree tree, Object value, boolean isSelected, boolean expanded, boolean isLeaf, int row, boolean isFocused) {
   String string = tree.convertValueToText(value, isSelected, expanded, isLeaf, row, isFocused);
   this.isFocused = isFocused;
   this.isSelected = isSelected;
   setText(string);
   setForeground(UIManager.getColor(isSelected ? "Tree.selectionForeground" : "Tree.textForeground"));
   preferredHeight = 0; // By default, don't override width/height
   if (do_isDouble(value)) { Dimension d = super.getPreferredSize(); preferredWidth=d.width+3; preferredHeight=d.height*2; }
   return this;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:13,代码来源:OurTree.java

示例3: getTreeCellRendererComponent

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * This is messaged from JTree whenever it needs to get the size
 * of the component or it wants to draw it.
 * This attempts to set the font based on value, which will be
 * a TreeNode.
 */
public Component getTreeCellRendererComponent(JTree tree, Object value,
        boolean selected, boolean expanded,
        boolean leaf, int row,
        boolean hasFocus) {
    String stringValue = tree.convertValueToText(value, selected,
            expanded, leaf, row, hasFocus);

    /* Set the text. */
    setText(stringValue);
    /* Tooltips used by the tree. */
    setToolTipText(stringValue);

    /* Set the image. */
    if (expanded) {
        setIcon(expandedIcon);
    } else if (!leaf) {
        setIcon(collapsedIcon);
    } else {
        setIcon(null);
    }

    /* Set the color and the font based on the SampleData userObject. */
    SampleData userObject = (SampleData) ((DefaultMutableTreeNode) value).
            getUserObject();
    if (hasFocus) {
        setForeground(UIManager.getColor("Tree.selectionForeground"));
    } else {
        setForeground(userObject.getColor());
    }
    if (userObject.getFont() == null) {
        setFont(defaultFont);
    } else {
        setFont(userObject.getFont());
    }

    /* Update the selected flag for the next paint. */
    this.selected = selected;

    return this;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:47,代码来源:SampleTreeCellRenderer.java

示例4: getTreeCellRendererComponent

import javax.swing.JTree; //导入方法依赖的package包/类
/**
  * Configures the renderer based on the passed in components.
  * The value is set from messaging the tree with
  * <code>convertValueToText</code>, which ultimately invokes
  * <code>toString</code> on <code>value</code>.
  * The foreground color is set based on the selection and the icon
  * is set based on the <code>leaf</code> and <code>expanded</code>
  * parameters.
  */
public Component getTreeCellRendererComponent(JTree tree, Object value,
                                              boolean sel,
                                              boolean expanded,
                                              boolean leaf, int row,
                                              boolean hasFocus) {
    String         stringValue = tree.convertValueToText(value, sel,
                                      expanded, leaf, row, hasFocus);

    this.tree = tree;
    this.hasFocus = hasFocus;
    setText(stringValue);

    Color fg = null;
    isDropCell = false;

    JTree.DropLocation dropLocation = tree.getDropLocation();
    if (dropLocation != null
            && dropLocation.getChildIndex() == -1
            && tree.getRowForPath(dropLocation.getPath()) == row) {

        Color col = DefaultLookup.getColor(this, ui, "Tree.dropCellForeground");
        if (col != null) {
            fg = col;
        } else {
            fg = getTextSelectionColor();
        }

        isDropCell = true;
    } else if (sel) {
        fg = getTextSelectionColor();
    } else {
        fg = getTextNonSelectionColor();
    }

    setForeground(fg);

    Icon icon = null;
    if (leaf) {
        icon = getLeafIcon();
    } else if (expanded) {
        icon = getOpenIcon();
    } else {
        icon = getClosedIcon();
    }

    if (!tree.isEnabled()) {
        setEnabled(false);
        LookAndFeel laf = UIManager.getLookAndFeel();
        Icon disabledIcon = laf.getDisabledIcon(tree, icon);
        if (disabledIcon != null) icon = disabledIcon;
        setDisabledIcon(icon);
    } else {
        setEnabled(true);
        setIcon(icon);
    }
    setComponentOrientation(tree.getComponentOrientation());

    selected = sel;

    return this;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:71,代码来源:DefaultTreeCellRenderer.java


注:本文中的javax.swing.JTree.convertValueToText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。