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


Java DefaultTreeCellRenderer.setTextNonSelectionColor方法代码示例

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


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

示例1: interactiveCompareTreeExtTreeColors

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * Custom tree colors in JTree. Compare core default renderer with Swingx
 * default renderer.
 * 
 */
public void interactiveCompareTreeExtTreeColors() {
    JTree xtree = new JTree();
    Color background = Color.MAGENTA;
    Color foreground = Color.YELLOW;
    xtree.setBackground(background);
    xtree.setForeground(foreground);
    DefaultTreeCellRenderer coreTreeCellRenderer = new DefaultTreeCellRenderer();
    // to get a uniform color on both tree and node
    // the core default renderer needs to be configured
    coreTreeCellRenderer.setBackgroundNonSelectionColor(background);
    coreTreeCellRenderer.setTextNonSelectionColor(foreground);
    xtree.setCellRenderer(coreTreeCellRenderer);
    JTree tree = new JTree();
    tree.setBackground(background);
    tree.setForeground(foreground);
    // swingx renderer uses tree colors
    tree.setCellRenderer(xTreeRenderer);
    final JXFrame frame = wrapWithScrollingInFrame(xtree, tree,
            "custom tree colors - core vs. ext renderer");
    frame.setVisible(true);
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:27,代码来源:TreeRendererTest.java

示例2: configureRenderer

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
private void configureRenderer(SynthContext context) {
    TreeCellRenderer renderer = tree.getCellRenderer();

    if (renderer instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer r = (DefaultTreeCellRenderer)renderer;
        SynthStyle style = context.getStyle();

        context.setComponentState(ENABLED | SELECTED);
        Color color = r.getTextSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setTextSelectionColor(style.getColor(
                                 context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setBackgroundSelectionColor(style.getColor(
                                    context, ColorType.TEXT_BACKGROUND));
        }

        context.setComponentState(ENABLED);
        color = r.getTextNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setTextNonSelectionColor(style.getColorForState(
                                    context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setBackgroundNonSelectionColor(style.getColorForState(
                              context, ColorType.TEXT_BACKGROUND));
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:SynthTreeUI.java

示例3: applyRenderer

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * Performs configuration of the tree's renderer if the adapter's column is
 * the hierarchical column, does nothing otherwise.
 * <p>
 * 
 * Note: this is legacy glue if the treeCellRenderer is of type
 * DefaultTreeCellRenderer. In that case the renderer's
 * background/foreground/Non/Selection colors are set to the tree's
 * background/foreground depending on the adapter's selection state. Does
 * nothing if the treeCellRenderer is backed by a ComponentProvider.
 * 
 * @param component the rendering component
 * @param adapter component data adapter
 * @throws NullPointerException if the specified component or adapter is
 *         null
 */
protected Component applyRenderer(Component component,
        ComponentAdapter adapter) {
    if (component == null) {
        throw new IllegalArgumentException("null component");
    }
    if (adapter == null) {
        throw new IllegalArgumentException("null component data adapter");
    }

    if (isHierarchical(adapter.column)) {
        // After all decorators have been applied, make sure that relevant
        // attributes of the table cell renderer are applied to the
        // tree cell renderer before the hierarchical column is rendered!
        TreeCellRenderer tcr = renderer.getCellRenderer();
        if (tcr instanceof JXTree.DelegatingRenderer) {
            tcr = ((JXTree.DelegatingRenderer) tcr).getDelegateRenderer();

        }
        if (tcr instanceof DefaultTreeCellRenderer) {

            DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
            // this effectively overwrites the dtcr settings
            if (adapter.isSelected()) {
                dtcr.setTextSelectionColor(component.getForeground());
                dtcr.setBackgroundSelectionColor(component.getBackground());
            } else {
                dtcr.setTextNonSelectionColor(component.getForeground());
                dtcr.setBackgroundNonSelectionColor(component
                        .getBackground());
            }
        }
    }
    return component;
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:51,代码来源:JXTreeTable.java

示例4: configureRenderer

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
private void configureRenderer(SeaGlassContext context) {
    TreeCellRenderer renderer = tree.getCellRenderer();

    if (renderer instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer r = (DefaultTreeCellRenderer) renderer;
        SeaGlassStyle style = (SeaGlassStyle)context.getStyle();

        context.setComponentState(ENABLED | SELECTED);
        Color color = r.getTextSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setTextSelectionColor(style.getColor(context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundSelectionColor();
        if (color == null || (color instanceof UIResource)) {
            r.setBackgroundSelectionColor(style.getColor(context, ColorType.TEXT_BACKGROUND));
        }

        context.setComponentState(ENABLED);
        color = r.getTextNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setTextNonSelectionColor(style.getColorForState(context, ColorType.TEXT_FOREGROUND));
        }
        color = r.getBackgroundNonSelectionColor();
        if (color == null || color instanceof UIResource) {
            r.setBackgroundNonSelectionColor(style.getColorForState(context, ColorType.TEXT_BACKGROUND));
        }
    }
}
 
开发者ID:khuxtable,项目名称:seaglass,代码行数:29,代码来源:SeaGlassTreeUI.java

示例5: getTableCellRendererComponent

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * TreeCellRenderer method. Overridden to update the visible row.
 */
public Component getTableCellRendererComponent(JTable table,
        Object value, boolean isSelected, boolean hasFocus, int row,
        int column) {
    Color background;
    Color foreground;

    if (isSelected) {
        background = table.getSelectionBackground();
        foreground = table.getSelectionForeground();
    } else {
        background = table.getBackground();
        foreground = table.getForeground();
    }
    highlightBorder = null;
    if (realEditingRow() == row && getEditingColumn() == column) {
        background = UIManager.getColor("Table.focusCellBackground");
        foreground = UIManager.getColor("Table.focusCellForeground");
    } else if (hasFocus) {
        highlightBorder = UIManager
                .getBorder("Table.focusCellHighlightBorder");
        if (isCellEditable(row, column)) {
            background = UIManager
                    .getColor("Table.focusCellBackground");
            foreground = UIManager
                    .getColor("Table.focusCellForeground");
        }
    }

    visibleRow = row;
    setBackground(background);

    TreeCellRenderer tcr = getCellRenderer();
    if (tcr instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
        if (isSelected) {
            dtcr.setTextSelectionColor(foreground);
            dtcr.setBackgroundSelectionColor(background);
        } else {
            dtcr.setTextNonSelectionColor(foreground);
            dtcr.setBackgroundNonSelectionColor(background);
        }
    }
    return this;
}
 
开发者ID:dvorka,项目名称:mindraider,代码行数:48,代码来源:JTreeTable.java

示例6: getTableCellRendererComponent

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * TreeCellRenderer method. Overridden to update the visible row.
 */
public Component getTableCellRendererComponent(JTable table,
		Object value, boolean isSelected, boolean hasFocus, int row,
		int column) {
	Color background;
	Color foreground;

	if (isSelected) {
		background = table.getSelectionBackground();
		foreground = table.getSelectionForeground();
	} else {
		background = table.getBackground();
		foreground = table.getForeground();
	}
	highlightBorder = null;
	if (realEditingRow() == row && getEditingColumn() == column) {
		// background = UIManager.getColor("Table.focusCellBackground");
		// foreground = UIManager.getColor("Table.focusCellForeground");
	} else if (hasFocus) {		
		if (isSelected) {
				highlightBorder = UIManager.getBorder("Table.focusSelectedCellHighlightBorder");
		}
		else{
			highlightBorder = UIManager.getBorder("Table.focusCellHighlightBorder");
		}				
		if (isCellEditable(row, column)) {
			// background = UIManager.getColor
			// ("Table.focusCellBackground");
			background = table.getSelectionBackground();
			foreground = table.getSelectionForeground();
		}
	}

	visibleRow = row;
	setBackground(background);

	TreeCellRenderer tcr = getCellRenderer();
	if (tcr instanceof DefaultTreeCellRenderer) {
		DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
		if (isSelected) {
			dtcr.setTextSelectionColor(foreground);
			dtcr.setBackgroundSelectionColor(background);
		} else {
			dtcr.setTextNonSelectionColor(foreground);
			dtcr.setBackgroundNonSelectionColor(background);
		}
	}		
	return this;
}
 
开发者ID:apache,项目名称:incubator-taverna-workbench,代码行数:52,代码来源:JTreeTable.java


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