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


Java DefaultTreeCellRenderer.setBackgroundSelectionColor方法代码示例

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


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

示例1: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * updateUI is overridden to set the colors of the Tree's renderer to
 * match that of the table.
 */
@Override
public void updateUI ()
{
    super.updateUI();

    // Make the tree's cell renderer use the table's cell selection
    // colors.
    TreeCellRenderer tcr = getCellRenderer();

    if (tcr instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);

        // For 1.1 uncomment this, 1.2 has a bug that will cause an
        // exception to be thrown if the border selection color is
        // null.
        dtcr.setBorderSelectionColor(null);
        dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
        dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
    }
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:25,代码来源:JTreeTable.java

示例2: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * UpdateUI is overridden to set the colors of the Tree's renderer
 * to match that of the table.
 */
@Override
public void updateUI() {
    super.updateUI();
    // Make the tree's cell renderer use the table's cell selection
    // colors.
    final TreeCellRenderer tcr = getCellRenderer();
    if (tcr instanceof DefaultTreeCellRenderer) {
        final DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tcr;
        // For 1.1 uncomment this, 1.2 has a bug that will cause an
        // exception to be thrown if the border selection color is
        // null.
        // renderer.setBorderSelectionColor(null);
        renderer.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
        renderer.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
    }
}
 
开发者ID:rnveach,项目名称:checkstyle-backport-jre6,代码行数:21,代码来源:TreeTableCellRenderer.java

示例3: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * updateUI is overridden to set the colors of the Tree's renderer to
 * match that of the table.
 */
public void updateUI() {
	super.updateUI();
	// Make the tree's cell renderer use the table's cell selection
	// colors.
	TreeCellRenderer tcr = getCellRenderer();
	if (tcr instanceof DefaultTreeCellRenderer) {
		DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
		// For 1.1 uncomment this, 1.2 has a bug that will cause an
		// exception to be thrown if the border selection color is
		// null.
		// dtcr.setBorderSelectionColor(null);
		dtcr.setTextSelectionColor(UIManager
				.getColor("Table.selectionForeground"));
		dtcr.setBackgroundSelectionColor(UIManager
				.getColor("Table.selectionBackground"));
		((DefaultTreeCellRenderer)this.getCellRenderer()).setLeafIcon(null);
		((DefaultTreeCellRenderer)this.getCellRenderer()).setOpenIcon(null);
		((DefaultTreeCellRenderer)this.getCellRenderer()).setClosedIcon(null);
	}
}
 
开发者ID:cst316,项目名称:spring16project-Modula-2,代码行数:25,代码来源:JTreeTable.java

示例4: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
     * updateUI is overridden to set the colors of the Tree's renderer to
     * match that of the table.
     */
    public void updateUI() {
        super.updateUI();
 
        // Make the tree's cell renderer use the table's cell selection
        // colors.
        TreeCellRenderer tcr = getCellRenderer();
        if (tcr instanceof DefaultTreeCellRenderer) {
            DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
 
dtcr.setBorderSelectionColor(null);
            dtcr.setTextSelectionColor(UIManager
                    .getColor("Table.selectionForeground"));
            dtcr.setBackgroundSelectionColor(UIManager
                    .getColor("Table.selectionBackground"));
        }
    }
 
开发者ID:cst316,项目名称:spring16project-Modula-2,代码行数:21,代码来源:TaskTable.java

示例5: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * updateUI is overridden to set the colors of the Tree's renderer to
 * match that of the table.
 */
@Override
public void updateUI() {
	super.updateUI();
	// Make the tree's cell renderer use the table's cell selection
	// colors.
	TreeCellRenderer tcr = getCellRenderer();
	if (tcr instanceof DefaultTreeCellRenderer) {
		DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
		// For 1.1 uncomment this, 1.2 has a bug that will cause an
		// exception to be thrown if the border selection color is
		// null.
		// dtcr.setBorderSelectionColor(null);
		dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
		dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
		((DefaultTreeCellRenderer) this.getCellRenderer()).setLeafIcon(null);
		((DefaultTreeCellRenderer) this.getCellRenderer()).setOpenIcon(null);
		((DefaultTreeCellRenderer) this.getCellRenderer()).setClosedIcon(null);
	}
}
 
开发者ID:cst316,项目名称:spring16project-Fortran,代码行数:24,代码来源:JTreeTable.java

示例6: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * updateUI is overridden to set the colors of the Tree's renderer to
 * match that of the table.
 */
@Override
public void updateUI() {
	super.updateUI();

	// Make the tree's cell renderer use the table's cell selection
	// colors.
	TreeCellRenderer tcr = getCellRenderer();
	if (tcr instanceof DefaultTreeCellRenderer) {
		DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);

		dtcr.setBorderSelectionColor(null);
		dtcr.setTextSelectionColor(UIManager.getColor("Table.selectionForeground"));
		dtcr.setBackgroundSelectionColor(UIManager.getColor("Table.selectionBackground"));
	}
}
 
开发者ID:cst316,项目名称:spring16project-Fortran,代码行数:20,代码来源:TaskTable.java

示例7: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * updateUI is overridden to set the colors of the Tree's renderer
 * to match that of the table.
 */
@Override
public void updateUI() {
    super.updateUI();
    // Make the tree's cell renderer use the table's cell selection
    // colors.
    // TODO JW: need to revisit...
    // a) the "real" of a JXTree is always wrapped into a DelegatingRenderer
    //  consequently the if-block never executes
    // b) even if it does it probably (?) should not 
    // unconditionally overwrite custom selection colors. 
    // Check for UIResources instead. 
    TreeCellRenderer tcr = getCellRenderer();
    if (tcr instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
        // For 1.1 uncomment this, 1.2 has a bug that will cause an
        // exception to be thrown if the border selection color is null.
        dtcr.setBorderSelectionColor(null);
        dtcr.setTextSelectionColor(
            UIManager.getColor("Table.selectionForeground"));
        dtcr.setBackgroundSelectionColor(
            UIManager.getColor("Table.selectionBackground"));
    }
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:28,代码来源:JXTreeTable.java

示例8: interactiveCoreRendererCustomColor

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * Custom renderer colors of core DefaultTreeCellRenderer not respected.
 * This is intentional: treeTable's highlighters must rule, so the
 * renderer colors are used to force the treecellrenderer to use the 
 * correct values.
 */
public void interactiveCoreRendererCustomColor() {
    JXTreeTable treeTable = new JXTreeTable(new FileSystemModel());
    treeTable.addHighlighter(HighlighterFactory.createSimpleStriping());
    DefaultTreeCellRenderer legacy = createBackgroundTreeRenderer();
    // in a treetable this has no effect: treetable.applyRenderer 
    // internally resets them to the same colors as tree itself
    // (configured by the table's highlighters
    legacy.setBackgroundNonSelectionColor(Color.YELLOW);
    legacy.setBackgroundSelectionColor(Color.RED);
    treeTable.setTreeCellRenderer(legacy);
    JTree tree = new JXTree(treeTable.getTreeTableModel());
    DefaultTreeCellRenderer other = createBackgroundTreeRenderer();
    other.setBackgroundNonSelectionColor(Color.YELLOW);
    other.setBackgroundSelectionColor(Color.RED);
    tree.setCellRenderer(other);
    JXFrame frame = wrapWithScrollingInFrame(treeTable, tree, "legacy renderers - highlight complete cell");
    frame.setVisible(true);  
}
 
开发者ID:RockManJoe64,项目名称:swingx,代码行数:25,代码来源:JXTreeTableIssues.java

示例9: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * updateUI is overridden to set the colors of the Tree's renderer to
 * match that of the table.
 */
public void updateUI() {
    super.updateUI();
    // Make the tree's cell renderer use the table's cell selection
    // colors.
    TreeCellRenderer tcr = getCellRenderer();
    if (tcr instanceof DefaultTreeCellRenderer) {
        DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
        // For 1.1 uncomment this, 1.2 has a bug that will cause an
        // exception to be thrown if the border selection color is
        // null.
        // dtcr.setBorderSelectionColor(null);
        dtcr.setTextSelectionColor(UIManager
                .getColor("Table.selectionForeground"));
        dtcr.setBackgroundSelectionColor(UIManager
                .getColor("Table.selectionBackground"));
    }
}
 
开发者ID:dvorka,项目名称:mindraider,代码行数:22,代码来源:JTreeTable.java

示例10: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
/**
 * updateUI is overridden to set the colors of the Tree's renderer
 * to match that of the table.
 */
public void updateUI() {
    super.updateUI();
    // Make the tree's cell renderer use the table's cell selection
    // colors.
    TreeCellRenderer tcr = getCellRenderer();
    if (tcr instanceof DefaultTreeCellRenderer) {
    DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer)tcr);
    // For 1.1 uncomment this, 1.2 has a bug that will cause an
    // exception to be thrown if the border selection color is
    // null.
    // dtcr.setBorderSelectionColor(null);
    dtcr.setTextSelectionColor(UIManager.getColor
                   ("Table.selectionForeground"));
    dtcr.setBackgroundSelectionColor(UIManager.getColor
                    ("Table.selectionBackground"));
    }
}
 
开发者ID:hypergraphdb,项目名称:viewer,代码行数:22,代码来源:JTreeTable.java

示例11: 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

示例12: updateUI

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
public void updateUI() {
  super.updateUI();
  TreeCellRenderer tcr = super.getCellRenderer();
  if (tcr instanceof DefaultTreeCellRenderer) {
    DefaultTreeCellRenderer dtcr = (DefaultTreeCellRenderer)tcr;
    dtcr.setTextSelectionColor(UIUtil.getTableSelectionForeground());
    dtcr.setBackgroundSelectionColor(UIUtil.getTableSelectionBackground());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:TreeTableTree.java

示例13: 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

示例14: 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

示例15: createDocPane

import javax.swing.tree.DefaultTreeCellRenderer; //导入方法依赖的package包/类
private JTree createDocPane() {
    final DefaultMutableTreeNode root = new DefaultMutableTreeNode();
    for (Map.Entry<?,? extends List<?>> docEntry : getDoc().getItemTree()
        .entrySet()) {
        DefaultMutableTreeNode node = new DefaultMutableTreeNode(docEntry.getKey());
        root.add(node);
        for (Object rule : docEntry.getValue()) {
            node.add(new DefaultMutableTreeNode(rule));
        }
    }
    final JTree result = new JTree(root) {
        @Override
        public String getToolTipText(MouseEvent evt) {
            if (getRowForLocation(evt.getX(), evt.getY()) == -1) {
                return null;
            }
            TreePath curPath = getPathForLocation(evt.getX(), evt.getY());
            Object userObject =
                ((DefaultMutableTreeNode) curPath.getLastPathComponent()).getUserObject();
            return getToolTip(userObject);
        }
    };
    result.setRootVisible(false);
    result.setShowsRootHandles(true);
    DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) result.getCellRenderer();
    renderer.setBackgroundNonSelectionColor(null);
    renderer.setBackgroundSelectionColor(null);
    renderer.setTextSelectionColor(null);
    renderer.setLeafIcon(null);
    renderer.setClosedIcon(null);
    renderer.setOpenIcon(null);
    result.setCellRenderer(renderer);
    ToolTipManager.sharedInstance()
        .registerComponent(result);
    result.addMouseListener(new DismissDelayer(result));
    for (int i = 0; i < root.getChildCount(); i++) {
        result
            .expandPath(new TreePath(((DefaultMutableTreeNode) root.getChildAt(i)).getPath()));
    }
    result.setBackground(null);
    return result;
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:43,代码来源:ControlDisplay.java


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